Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forward mail using Postfix move FROM to REPLY-TO then rewrite FROM

What I am trying to do is:

Setup a SMTP relay for outgoing mail where:
(a) All From: headers are rewritten to be "[email protected]"
(b) A Reply-To: header with the original From: address is added

I am using sender_cannoical_maps and header_checks, with the content of each as follows:

sender_canonical_maps:

/.*/    [email protected]

header_checks:

/^From:(.*)$/   PREPEND Reply-To:$1

But when a message is received, the no-reply address is included in the Reply-To: field, which I do not want:

to:         [email protected]
from:       [email protected]
reply-to:   [email protected], [email protected]

If I change header_checks to use REPLACE instead of PREPEND I lose the original sender which is overwritten:

to:         [email protected]    
from:       [email protected]
reply-to:   [email protected]

So I have lost [email protected].

What I am doing wrong here? And apologies in advance for any lack of info.

like image 347
pferg Avatar asked Aug 23 '15 02:08

pferg


People also ask

What is Mydestination in postfix?

The mydestination parameter specifies what domains this machine will deliver locally, instead of forwarding to another machine. The default is to receive mail for the machine itself. See the VIRTUAL_README file for how to configure Postfix for hosted domains.

What is Smtpd_relay_restrictions?

This is called allowlisting; the smtpd_relay_restrictions example above allows mail from local networks, and from SASL authenticated clients, but otherwise rejects mail to arbitrary destinations. The table below summarizes the purpose of each SMTP access restriction list.

What is postfix main CF?

Postfix main.cf file format. The Postfix main.cf configuration file specifies a very small subset of all the parameters that control the operation of the Postfix mail system. Parameters not explicitly specified are left at their default values.


1 Answers

If header_sender is in sender_canonical_classes (default) then postfix will rewrite both the From and Reply-To headers when processing sender_cannonical_maps. So the header_check adds the Reply-To and then the sender_cannonical_maps is rewriting the Reply-To. To keep your Reply-To added in header_checks you need

sender_canonical_classes = envelope_sender
sender_cannoical_maps = static:[email protected]

However this leave the From header unchanged, but you can rewrite it in smtp_header_checks by adding

smtp_header_checks = regex:/etc/postfix/smtp_header_checks

/etc/postfix/smtp_header_checks contents

/^From:(.*)$/   REPLACE From: [email protected]
like image 71
mklassen Avatar answered Oct 19 '22 03:10

mklassen