1

I would like to add a Postfix re-write rule to insert a Reply-To: header if there is not one already defined.

This server is a web server with PHP and Perl scripts, we do not want the mail sent from this server to reply back to this server. Some of the scripts specify Reply-To: headers, others do not. I want set Reply-To: webmaster@domain.tld if the script has not already set one.

Kent
  • 111
  • 4

1 Answers1

1

It would be better (and easier) to simply rewrite the sender's address; this will have the same effect, as well as doing some hiding of the internal topology (e.g. the sender won't anymore be something like apache@webserver6.example.com).

You can easily rewrite the sender of all outgoing mail with smtp_generic_maps. For instance, to change the sender of all outgoing mail to webmaster@example.com:

In /etc/postfix/main.cf:

smtp_generic_maps = hash:/etc/postfix/generic

In /etc/postfix/generic:

*                       webmaster@example.com

Then run postmap /etc/postfix/generic and service postfix reload.

See generic(5) for more options on rewriting sender addresses and the ADDRESS REWRITING README for everything you ever wanted to know about address transformations.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • Yep, that will work for changing ALL outgoing mail. Is there a conditional I can use to check if sender=apache then change sender to webmaster@example.com? Some of the scripts set the sender and reply-to so come thing like sales@example.com and accounting@example.com. I do not want to over write those. – Kent Apr 12 '14 at 21:03
  • Just use `apache@whatever` instead of the wildcard. But you did say you wanted to rewrite _all_ outgoing mail... – Michael Hampton Apr 12 '14 at 21:35