I have a development web server (CentOS LAMP stack) that uses the postfix SMTP relay setting to send email. We use mailgun with several users, the setting is similar to this , but with specific users, and not just wildcards:
/etc/postfix/main.cf
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_auth_enable = yes sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map smtp_sender_dependent_authentication = yes smtp_sasl_security_options = noanonymous relayhost = [smtp.mailgun.org]:587
/ etc / postfix / sasl_passwd
/ etc / postfix / relayhost_map
no-reply@domain.com [smtp.mailgun.org]:587 info@domain2.com [smtp.mailgun.org]:587 support@domain3.com [smtp.mailgun.org]:587
To set up email logging, I confirm that each developer on the computer has their own SMTP credentials. I want to configure it so that developers do not need to add additional_headers or additional_parameters to get the smtp relay matching in postfixes - and indeed, it will take a lot of work to configure different mail headers in the code for different developers, especially with the version of the code. I got distracted. This worked differently from the postfix side of things when I use the following:
mail(' email@address.tld ', 'subject', 'message here...', 'From: noreply@domain.com ', ' -fnoreply@domain.com ');
So, I added the following to the vhost configuration:
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fnoreply@domain.com "
which successfully allowed me to get rid of -f additional_parameter and still send correctly. Then I added the following:
php_value sendmail_from " noreply@domain.com "
In the phpinfo() dump, I see that the local value for sendmail_from set correctly, however now when I send an email, it appears as:
None@domain.com on behalf of Apache
It seems that the correct sender is (MIME, not an envelope, as postfix recognizes authentication and gives 250 big successes). When postfix registers with verbose, I only see links to the correct email address from the sender input attribute.
In the mail, I see the following information from the journal, however, for email when From: noreply@domain.com used From: noreply@domain.com :
... "envelope": { "transport": "smtp", "sender": " noreply@domain.com ", "sending-ip": "xxxx", "targets": " email@address.tld " }, "message": { "headers": { "to": " email@address.tld ", "message-id": " 2014061111016.ABC1D23456E@domain.com ", "from": " noreply@domain.com (Apache)", "subject": "Debug Test" }, "attachments": [], "recipients": [ " email@address.tld " ], "size": 654 }, ...
Interesting is the same log when From: noreply@domain.com present , message->headers->from set according to noreply@domain.com without adding (Apache) . Surely this means that this is a PHP error and that PHP is not using the sendmail_from value correctly?
So, considering all this, my resulting question is: how can I set the default MIME sender (From header) in PHP, except for the mail() function? Am I missing something using my / config method above, or is it just not possible? I am glad to think a little that this will save time for the reason that we want this feature.