How to correctly configure Postfix to route emails to aliases?
For the most part, I have successfully configured Postfix to send emails. Emails sent to outside domains, e.g. firstname.lastname@example.org, are delivered fine. The problem I’m having is when I send emails from my website’s contact form, via the PHP mail() function, to my domain’s own email addresses.
Here are the problems I’m experiencing:
- Emails sent to my user name, e.g. email@example.com go to /var/mail/myname but are not sent to the Google Apps account that my MX records point to. They also have the return path header overwritten to be firstname.lastname@example.org.
- Emails sent to aliases, e.g. email@example.com, are sent to /var/mail/myname with a message: Action: failed, Status: 5.1.1, Diagnostic-Code: X-Postfix; unknown user: “support”. The error message shows that the return path header has been overwritten, but in this case to
- All the emails have the return path header information overwritten. In the php mail() function, the return path is set to firstname.lastname@example.org but is changed to email@example.com in the emails that result in an error and firstname.lastname@example.org in the emails that get successfully delivered.
- myorigin = mydomain.com
- mydestination = mydomain.com, localhost.mydomain.com, , localhost
- email@example.com myname
- firstname.lastname@example.org myname
- email@example.com myname
- firstname.lastname@example.org myname
I ran postmap on /etc/postfix/virtual and /etc/init.d/postfix reload before attempting the send the emails.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×