Suppose I have a VPS with multiple dedicated IP addresses and multiple domains:
domain-a.com
is on11.11.11.11
, mx ismail.domain-a.com
domain-b.com
is on22.22.22.22
, mx ismail.domain-b.com
domain-c.com
is on33.33.33.33
, mx ismail.domain-c.com
domain-a.com
is the primary domain and the server's hostname is server.domain-a.com
Everything seems to be fine until I find that SMTP emails sent using Exim 4.72 are bouncing, failing or being flagged as spam to many domains. After some digging, I discover that there are mismatches: for emails from every domain, the HELO
is from server.domain-a.com
.
For example, I see this in headers on emails I send to gmail:
Received: from server.domain-a.com (mail.domain-c.com. [33.33.33.33])
And a mail testing service like https://www.mail-tester.com/ tells me:
Your reverse DNS does not match with your sending domain.
Your IP address 33.33.33.33 is associated with the domain mail.domain-c.com.
Nevertheless your message appears to be sent from server.domain-a.com.
You may want to change your pointer (PTR type) DNS record and the host name of your server to the same value.
Here are the tested values for this check:
IP: 33.33.33.33 HELO: server.domain-a.com rDNS: mail.domain-c.com
But obviously I can't point server.domain-a.com
at domains a, b and c at once, and anyway, I don't necessarily want domain-c.com to be sending via domain-a.com – let's assume they're independent businesses that just happen to be hosted on the same server.
How can I configure exim to send each email from its own domain, and to HELO
from the mail server domain, not the server's primary hostname?
So that the headers look like this:
Received: from mail.domain-c.com (mail.domain-c.com. [33.33.33.33])
And the testing results report this:
IP: 33.33.33.33 HELO: mail.domain-c.com rDNS: mail.domain-c.com
I found a solution to this same question for IP addresses, which is how I'm sending mail from different IPs, so I'm sure there must be a similar solution for domains.
In my research all I could find was this solution but it depends on cP***l and W*M and a file /etc/mailhelo
that only exists in cP***l. It's clearly possible, but that solution depends on some behind the scenes gubbins baked into cP***l, which I don't use.
Operating system is CentOS if that's relevant.
Best Answer
Well, that was easier than expected.
I noticed my exim settings file (
/etc/exim/exim.conf
) contained this commented out line:Uncommenting it out caused the HELO / from to become the right domain, just missing the
mail.
prefix.So what worked for me was:
(1) Under
remote_smtp:
in my exim config file, which on my system was located at/etc/exim/exim.conf
, adding the following line:(2) Restarting exim (on my system, that was
service exim restart
)(3) That's all
After making this change, services like Mail Tester find no problems, and this section of my mail headers look normal:
The hostname does still appear later on in the email headers; I've asked a separate question about that.