I'm trying to set up postfix as a relay for Amazon SES. SES will only allow emails to be sent from particular (verified) email addresses. This part works. Now I need to integrate with PHP.
What I need is to support multiple verified email addresses, e.g. firstname.lastname@example.org, email@example.com. I need postfix to set the
X-Postfix-Sender header to the value of the 'From' header I pass into the mail() call. Unfortunately it sets
X-Postfix-Sender: rfc822; firstname.lastname@example.org instead.
I'm sending emails using:
mail('email@example.com', 'PHP test', 'Test message from PHP at ' . $time, "From: firstname.lastname@example.org");
In the logs I get a refusal from SES: "Diagnostic-Code: smtp; 554 Message rejected: Email address is not verified."
sendmail_path = /usr/sbin/sendmail -t but this doesn't seem to make much difference.
How can I make postfix set the
X-Postfix-Sender header to the value of the 'From' header?
========================== ANSWER ==========================
I can do what I want by using the
additional_parameters option of PHP's mail() method:
mail('email@example.com', 'PHP test', 'Test message from PHP at ' . $time, '', "-f firstname.lastname@example.org");
This passes the '-f' flag and a from address to sendmail.