17

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.

csi
  • 1,535
  • 7
  • 22
  • 42

4 Answers4

16

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.

Søren Løvborg
  • 542
  • 4
  • 10
5

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.

ah83
  • 1,062
  • 9
  • 8
0

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

Shapeshifter
  • 254
  • 1
  • 6
-1

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

Frederick Nord
  • 181
  • 1
  • 8