Relay Server settings for Exim to connect through SMTP/Mailgun

domain-name-systemsmtp

What I'm trying to do:
Send out WordPress notifications using SMTP/Mailgun instead of PHPmailer.

  • I have a production VPS with one IP and several WordPress installs with different domains. It has WHM & cPanel with exim/dovcot.

The mail port for it is blocked so I had to create a relay server with exim/dovcot. With this install I do not have WHM or cPanel.

Currently WordPress is able to send out emails using PHPMailer and the relay is working fine, but I'm unable to send WP notifications to Google Apps. It works fine with a regular gmail account but not G-apps.

I'd rather use a service like Mailgun to receive emails from WordPress and then send them out through Mailgun to whomever they need to go to for each domain using a subdomain.

Currently I have the required dns setup with mailgun and the subdomain is validated. I setup the TXT, CNAME and MX records in Godaddy and I have the records pointing to a subdomain. mg.mydomain.com

Is there anything I need to setup or change with either of my servers to allow SMTP to work with Mailgun?

Is there anything I need to change in WHM / Cpanel

Domain Verification Screenshot

Any help would be very appreciated. If you have a better suggestion as to how to get around the blocked port please let me know.
Thanks in advance!

Best Answer

By default WHM restricts outgoing SMTP connections, in Tweak Settings under Mail section you need to turn off "Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)"

BE WARNED! I've found that shortly after turning this off spam server bots will discover this has been turned off and start using your server as their own relay thereby getting you blacklisted and wasting bandwidth.

The following link is an instruction set to configure Exim to use Mailgun as a server wide email relay but this is problematic since Mailgun is designed to use different logins for different domains. https://grepitout.com/configure-mailgun-cpanel-exim/

UPDATE SOLVED

I've detailed my working solution here, Exim Smarthost Multiple domains and credentials Mailgun

Now I just add domains to Mailgun, Set MX Records in cPanel/WHM and modify a credentials text file on my server to get new sites working.