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 myemail@mydomain.com as the Envelope From address?

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

4 Answers 4


Put the following in /etc/postfix/canonical:

# Use the empty regexp to map *any* address to the desired envelope sender.
// my-fixed-envelope-sender@example.org

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.

  • Don't use // as that also matches the null sender e.g. for delivery errors. Use /./
    – wurtel
    Mar 14, 2019 at 10:03

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 -fyou@example.com"

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 -fyou@example.com"

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

  • It is also possible to use -F option to set name before mail: -F abc -> abc <you@example.com> Jun 28, 2019 at 9:08

I believe what you are looking for is the masquerade_domains setting which will go in main.cf. I am not sure what you mean by

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

Please take a look at the following link:

Postfix Configuration Parameters - masquerade_domains


Both questions have good answers: Change Envelope From to match From header in Postfix and how to have all postfix emails have ONE from email address

You probably want sender_canonical_maps=myemail@mydomain.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.