How do I fix my DigitalOcean LAMP server to send php email from multiple domains?

June 3, 2018 88 views
Email LAMP Stack PHP Ubuntu 16.04

In PHP, I'm using mail($to, $subject, $content, $headers, '-f') and I successfully receive the email at However, the "from" return address (in Yahoo! Mail) shows as "" instead "". My /var/logs/mail.log looks like:

Jun  2 18:30:39 domain1 sendmail[2872]: w531Udbv002872: from=, size=6059, class=0, nrcpts=1, msgid=<20180>, relay=www-data@localhost
Jun  2 18:30:39 domain1 sm-mta[2873]: w531UdPW002873: from=<u>, size=6279, class=0, nrcpts=1, msgid=<20180>, proto=ESMTP, daemon=MTA-
v4, relay=localhost []
Jun  2 18:30:39 domain1 sendmail[2872]: w531Udbv002872: to=ya, delay=00:00:00, xdelay=00:00:00, mailer=r
elay, pri=36059, relay=[] [], dsn=2.0.0, st
at=Sent (w531UdPW002873 Message accepted for delivery)
Jun  2 18:30:40 domain1 sm-mta[2875]: STARTTLS=client, relay=, version=TLSv1.2, verify=FAIL, cipher=
ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Jun  2 18:30:41 domain1 sm-mta[2875]: w531UdPW002873: to=<yah>, delay=00:00:02, xdelay=00:00:02, mailer=e
smtp, pri=126279, [
7], dsn=2.0.0, stat=Sent (ok dirdel)

As you can see, I'm using sendmail (8.15.2) and I'm looking only to send mail out from multiple domains (,,, etc). I've tried all kinds of sendmail files, features and commands:,, use_ct_file, use_cw_file, mailertable, virtusertable, genericstable, local-host-names, trusted-users, GENERICS_DOMAIN(), RELAY_DOMAIN(), sendmailconfig. SMART_HOST seemed to break everything.

The configuration always uses the line from /etc/hosts that looks like: localhost localhost.localdomain

I've tried messing around with MX and TXT (SPF) records but I don't know what I'm doing:

MX 10 14400
TXT v=spf1 ip4: a mx -all 3600

sm-mta seems to be converting to Also, verify=FAIL looks suspicious.

Can you help me interpret what is going on here and what I can do to fix it? Can I fix sendmail to pass through the "from" address rather than always changing it to what is in /etc/hosts?

I don't need to receive email but I'm willing to set it up if it helps with verification. I'm also willing to switch from sendmail to exim4 or something else if that will help.

Be the first one to answer this question.