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!

  • Your domain key should start with "v=DKIM1; and the k=rsa; is not needed. I don't see any other obvious errors. – BillThor Jun 7 '16 at 4:58
  • Yea, that's not the issue. Those are the required DNS records by Mailgun. That's why it's verified if you click that link. It's something to do with updating Exim settings on my relay server. – Mike Jun 7 '16 at 18:36
  • For Exim, you should configure it using the smarthost setting, and use the Mailgun server as your relay. – BillThor Jun 8 '16 at 4:36
  • So if my main server has a block for port 25 do I still need that other relay server to talk to Mailgun? – Mike Jun 8 '16 at 16:44
  • If port 25 is blocked, you still should be able to submit using the Submission port (587). You may need to setup client credentials in Exim. These should be your submission credentials for Mailgun. You will need to set the port when you specify the relay server address. – BillThor Jun 8 '16 at 20:38

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/


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.