I have A VPS with multiple domains setup. Some of the domains have PHP sites that send email. It turns out that some email servers are rejecting those emails with error: "Sender address rejected: Domain not found".(This from logs in exim_mainlog on server).
The interesting thing is that the domain it is reporting to be using as the sender is not the one I set in php mail(), rather an internal server name.
So for example if my VPS master domain is mymasterdomain.com and I have multiple sites such as site1.com, site2.com, etc, then the php program that sends email will send the email with a from field set in the header to: firstname.lastname@example.org but the mail will be rejected with 'Sender address rejected: Domain not found in email@example.com'.
com.mymasterdomain.com is how the hosting company identifies my VPS server internally, and obviously it does not resolve to anything.
SPF records are set properly to include the IP address of the site. I did a test by using php to snd the same email to two addresses. One is rejecting it, but the other at a gmail account is accepting it, which lets me look at the headers.
I can see the problem- the headers have:
Received: from cpanelSite1Account by com.mymasterdomain.com with local (Exim 4.91) (envelope-from ) id 1fWXCF-0006ED-Vv; Fri, 22 Jun 2018 09:37:56 -0500
Subject: NEW INQUERY RECEIVED
X-PHP-Script: www.site1.com/inquire_process.php for XXX.XXX.XXX.XXX
The [From:] is correct, but the [Received: from] contains the VPS info which is giving me trouble.
How do I fix this? In php? in cpanel? in sendmail or exim settings? Any help would be appreciated - have been scratching my had a while now ...