How do I change the Envelope From in Postfix?

Linux server that uses Postfix to send mail via Amazon SES. When sending email from Wordpress, the emails are rejected due to an improper Envelope From address.

How can I configure Postfix to always use [email protected] as the Envelope From address?

I am looking for a default property I can configure and not a code based solution.


Put the following in /etc/postfix/canonical:

# Use the empty regexp to map *any* address to the desired envelope sender.
// [email protected]

Append the following to /etc/postfix/main.cf:

canonical_maps = regexp:/etc/postfix/canonical
canonical_classes = envelope_sender

Reload Postfix:

postfix reload

Note that this only rewrites the envelope sender (as asked), not the "From:" header. Also, if you set this on a host that receives mail from the outside world, havoc will likely ensue.

See canonical(5) and the documentation for the canonical_maps and canonical_classes options for more information.


You can also set the envelope-sender from php.

Put this in your apache vhost config if you are using mod_php:

php_admin_value sendmail_path "/usr/sbin/sendmail -t -i [email protected]"

Or set the value in the php.ini file (which could be server wide or per user depending on your system):

sendmail_path "/usr/sbin/sendmail -t -i [email protected]"

this only works if the sending script uses the php mail() function.