How do I fix my DigitalOcean LAMP server to send php email from multiple domains?
In PHP, I’m using mail($to, $subject, $content, $headers, ’-f firstname.lastname@example.org’) and I successfully receive the email at email@example.com. However, the “from” return address (in Yahoo! Mail) shows as “firstname.lastname@example.org” instead “email@example.com”. My /var/logs/mail.log looks like:
Jun 2 18:30:39 domain1 sendmail: w531Udbv002872: from= firstname.lastname@example.org, size=6059, class=0, nrcpts=1, msgid=<20180 6030130.w531Udbv002872@domain1.com>, relay=www-data@localhost Jun 2 18:30:39 domain1 sm-mta: w531UdPW002873: from=<u email@example.com>, size=6279, class=0, nrcpts=1, msgid=<20180 6030130.w531Udbv002872@domain1.com>, proto=ESMTP, daemon=MTA- v4, relay=localhost [127.0.0.1] Jun 2 18:30:39 domain1 sendmail: w531Udbv002872: to=ya firstname.lastname@example.org, delay=00:00:00, xdelay=00:00:00, mailer=r elay, pri=36059, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, st at=Sent (w531UdPW002873 Message accepted for delivery) Jun 2 18:30:40 domain1 sm-mta: STARTTLS=client, relay= mta6.am0.yahoodns.net., version=TLSv1.2, verify=FAIL, cipher= ECDHE-RSA-AES128-GCM-SHA256, bits=128/128 Jun 2 18:30:41 domain1 sm-mta: w531UdPW002873: to=<yah email@example.com>, delay=00:00:02, xdelay=00:00:02, mailer=e smtp, pri=126279, relay=mta6.am0.yahoodns.net. [188.8.131.52 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 (domain1.com, domain2.com, domain3.com, etc). I’ve tried all kinds of sendmail files, features and commands: sendmail.mc, submit.mc, 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:
127.0.0.1 localhost domain1.com localhost.localdomain
I’ve tried messing around with MX and TXT (SPF) records but I don’t know what I’m doing:
MX domain2.com 184.108.40.206 10 14400
TXT domain2.com v=spf1 ip4:220.127.116.11 a mx -all 3600
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.
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.×