3

I want to make a header check rule to add a reply-to and change From to a no-reply. I use it for sort of diffusion list adress

I have tried this regexp code but it is not working:

if !/^From:(.+@myserver\.fr)/
/^From:(.*)$/ PREPEND Reply-To:$1
/^From:(.*)$/ REPLACE From: no-reply@myserver.fr
endif

Only the first action is use.

Can someone explain me what I am doing wrong?

Jos
  • 111
  • 1
  • 9

3 Answers3

1

The problem is with your match regex. You are matching the same header twice and thats not possible with header checks. if you can set the reply to in the email client you can just replace the from address with header checks and the case is solved.

if !/^From:(.+@myserver\.fr)/
/^From:(.*)$/ REPLACE From: no-reply@myserver.fr
endif
Farhad Farahi
  • 35,528
  • 7
  • 73
  • 70
  • Thanks for your answer, but there is a problem with your solution: the `$1` will not be matched by the Subject, so I don't know what to `PREPEND` with `Reply-To` – Jos Sep 09 '16 at 12:50
  • Thanks again, but this time the problem is that I loose the `Reply-To` part which is quite embarassing :) – Jos Sep 10 '16 at 20:10
1

The easy way that I found to fix something similar like this was, creating two files with regex sentences, to do this I edited the main.cf and I added these two files:

smtp_header_checks = regexp:/etc/postfix/header_checks
header_checks = pcre:/etc/postfix/add_original_rcpt.pcre

and I put one regex sentence in each file, and it works for me.

0

Replace From header

The above syntax looks wrong try as below,enable header_checks with postfix main.cf

Append the lines as below in header_checks file,Next if u want to add Reply_To header next to From header,do as below

/^From:[[:space:]]+(.*)/ REPLACE From: noreply@domain.com,

Prepend or Add new Header .* explains next to

/^From:.*/ PREPEND Reply_To: xyz@domain.com

If you want to set return path set using canonical_maps