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 [email protected] as the Envelope From address?

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

4 Answers 4

17

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.

1
  • Don't use // as that also matches the null sender e.g. for delivery errors. Use /./
    – wurtel
    Mar 14, 2019 at 10:03
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 [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.

1
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

-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 [email protected]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .