S
S
Semen Semenov2016-10-22 16:48:55
postfix
Semen Semenov, 2016-10-22 16:48:55

How to replace part of a line in a message header?

Hello!
You need to replace part of the line in the postfix message header.
Not enough knowledge in regular expressions, please help!
Header needed:

Received: from mysite.ru (snd1.mysite.ru [95.ххх.224.235])
  by snd1.mysite.ru (Postfix) with ESMTP id CCF64C02B4
  for <[email protected]>; Sat, 22 Oct 2016 15:16:02 +0300 (MSK)

replaced by:
Received: by mx.mysite.ru (Postfix, from userid 0)
  id 9095FC0240; Sat, 22 Oct 2016 14:56:23 +0300 (MSK)

Moreover, the replaced header can contain both domain.com and sub.domain.com
Also, some mail providers (Google for example) write a line without hyphens, like this:
Received: from mysite.ru (snd1.mysite.ru [95.ххх.224.235]) by snd1.mysite.ru (Postfix) with ESMTP id CCF64C02B4 for <[email protected]>; Sat, 22 Oct 2016 15:16:02 +0300 (MSK)

As a result, you just need to remove the following words from the line:
from mysite.ru (snd1.mysite.ru [95.ххх.224.235])
with ESMTP
for <[email protected]>
Please help me write a regular expression for the regexp file: /etc/postfix/header_checks
ххххх REPLACE ххххх
for clarity, you need to remove the words in bold:
Received: from mysite.ru (snd1.mysite.ru [95.ххх.224.235])
by snd1.mysite.ru (Postfix) with ESMTP id CCF64C02B4
for <[email protected]> ; Sat, 22 Oct 2016 15:16:02 +0300 (MSK)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question