Exim Smarthost Multiple domains and credentials Mailgun

0

I have the same setup (VPS + WHM/cPanel + Exim + Mailgun) and after doing some online research, I've found a few helpful websites regarding this topic and managed to come out with the correct configuration. Below are the solutions that I'm currently using on my VPS and hope it will help you as well. It should solve your "via" problem and might solve the intermittent "550 5.7.1 Relaying denied" error from Mailgun as well:



Go to the "Exim Configuration Editor" in WHM. Choose "Advanced Editor" and insert the configuration below:



Section: AUTH

mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = ": ${extract{login}{${lookup{$sender_address_domain}lsearch{/etc/exim_mailgun}{$value}fail}}} : ${extract{password}{${lookup{$sender_address_domain}lsearch{/etc/exim_mailgun}{$value}fail}}}"



Section: ROUTERSTART

mailgun:
driver = manualroute
domains = ! +local_domains
transport = mailgun_transport
route_list = "* smtp.mailgun.org::587 byname"
host_find_failed = defer
no_more



Section: TRANSPORTSTART

mailgun_transport:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org



Then create a file named /etc/exim_mailgun and insert the content similar to the structure below (Replace it with your Mailgun's domain login credentials that was verified):

domain1.com:    username=postmaster@mg.domain1.com     password=abcdefghi
domain2.com:    username=postmaster@mg.domain2.com     password=jklmnopqr



UPDATE:

As commented by @Supamic, I've sometimes encountered the error that he mentioned when the email was sent by Mail Delivery System (Mailer-Daemon@hostname.yourserver.com) to my external email account (Gmail):

authentication required but authentication attempt(s) failed


My guess is perhaps due to Mailer-Daemon “Sender identification” part as Exim was not able to grab the login credentials from my /etc/exim_mailgun as there’s no sender’s domain:

“Sender identification U=mailnull D=-system- S=mailnull”

To resolve this problem, cPanel tech support recommended that I've forward all the email from Mailer-Daemon to a local email address hosted on my server and then use the forwarder function to pass the email to my Gmail account.



As for the intermittent "550 5.7.1 Relaying denied" error, after contacting cPanel tech support, the recommendation that they gave me is to force smtp.mailgun.org to a single IP by setting a static IP in /etc/hosts instead of allowing Exim to resolve smtp.mailgun.org to multiple IPs.

The authentication error will start to happen when Exim's resolved smtp.mailgun.org to multiple IPs. The cPanel tech support unable to point the exact cause for this "550 5.7.1 Relaying denied" error. Perhaps something is not working right with Mailgun's maintaining their authentication across their redundant SMTP infrastructure.

You can resolve Mailgun's SMTP server IPs by using either one of the commands below:

nslookup smtp.mailgun.org

dig +short smtp.mailgun.org @resolver1.opendns.com


Use one of the IP from the result and put it within you /etc/hosts file:

xxx.xxx.xxx.xxx     smtp.mailgun.org


Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation