I have the following config file for msmtp
account default
host SES_HOST
port 587
timeout 5
auth on
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
syslog on
set_from_header on
allow_from_override off
user SES_USERNAME
password SES_PASSWORD
from SES_VERIFIED_EMAIL
php.ini
sendmail_path = /usr/local/bin/msmtp -ti
I want to make sure all emails sent via php use the SES_VERIFIED_EMAIL in the from header so SES does NOT reject the email. I thought setting the from
allow_from_override on
and allow_from_override off
would mean that email send from php with a from header that is NOT SES_VERIFIED_EMAIL would be replaced by SES_VERIFIED_EMAIL so the message will be sent
But I can only send emails via php where the from header is already put in as SES_VERIFIED_EMAIL
but I need it to work in all cases. It doesn't appear the from header is being replaced
I want msmtp to override the From header to SES_VERIFIED_EMAIL
so it does get sent. I thought the settings above would do it.
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: NOTSESVERIFYED@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>