Exim4 and different HELO for all domain on VPS

exim

Let's say I have domain.com , domain2.com, domain3.com on same VPS and all of them send mail, but Helo of all messages from all domains is localhost which gets rejected by some mail providers. How to make exim4 set helo to domain name from where it's sending mail. Like if I'm sending mail from domain.com helo should be domain.com. Other question, is this right thing to do?

UPD I changed my mind. I just want to set it to FQDN of box.

Best Answer

The smtp transport has a helo_data setting. By default it is set to $primary_hostname, which is why the first person's advice would work just fine if you wanted to configure the primary_hostname setting to a single, valid hostname. Since you seem to want to make it HELO with a dynamic hostname, you have to add a little logic to figure out which name it should use.

Somewhere in your DATA acl, you could detect those specific domains and set a variable. This is a very simple example (you could enhance by using file or database lookups) :

warn  domains      = domain1.com : domain2.com : domain3.com
      set acl_m_special_dom = mail.$domain

Look in your logs to determine which smtp transport is being used to send this email. Edit that transport and add a helo_data line that examines that acl message variable and adjusts the hostname that exim will use to HELO/EHLO with:

helo_data = ${if eq{$acl_m_special_dom}{}  \
                     {$primary_hostname}   \
                     {$acl_m_special_dom} }

The test checks if the variable is empty. If it's empty, it will use $primary_hostname. But if it is not empty, then it must have been set in the ACL condition above so it uses that hostname in the EHLO. This variable is a per message variable, so it gets cleared inbetween each message (if multiple messages are coming down in one connection).

You must make sure that any hostname you use here is resolvable in public DNS (test using Google's DNS), and that the IP it resolves too also has a reverse DNS. The rDNS does not need to match the hostname you use, but it needs to resolve to something. And if it reverse resolves to something that looks dynamic like a cablemodem or dsl line, it will likely still get blocked or deferred by most major mail providers.

Back to your description, it sounds like you are using the Debian split configuration system. They have a macro that will vary the HELO hostname based on the sender IP address that connects to your exim server. This will not work for you though if your email is sourced from one common server, meaning you need to vary this HELO hostname based on the sender domain name as shown above.

Related Topic