I have a GCP instance running with whm/cpanel and mailgun setup using exim for multiple accounts using multiple domains.
The current setup works for all domains however it only validates for the main domain. Mailgun supports multiple domains with multiple credentials.
When sending an email from a domain other than 'c*********t.com' emails have the VIA in gmail because the header.from
does't match.
dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=c*****s.com
Screenshot of 'VIA' and 'Images are not displayed'
Section: AUTH
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : postmaster@c*********t.com :
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Section: ROUTERSTART
mailgun:
driver = manualroute
domains = ! +local_domains
transport = mailgun_transport
route_list = "* smtp.mailgun.org::2525 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
Any suggestions or alternatives would be appreciated. Thank you.
UPDATE
Current Errors in log based on the answer provided below:
LOG: MAIN
cwd=/usr/local/cpanel/whostmgr/docroot 4 args: /usr/sbin/exim -v -M
1gPYIq-0001cc-UL
delivering 1gPYIq-0001cc-UL
Transport port=25 replaced by host-specific port=2525
Connecting to smtp.mailgun.org [**.**.**.***]:2525 ... connected
SMTP<< 220 ak47 ESMTP ready
SMTP>> EHLO instance-1
SMTP<< 250-ak47
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-SMTPUTF8
250 STARTTLS
SMTP>> STARTTLS
SMTP<< 220 2.0.0 Start TLS
SMTP>> EHLO instance-1
SMTP<< 250-ak47
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-ENHANCEDSTATUSCODES
250 SMTPUTF8
SMTP>> AUTH LOGIN
SMTP<< 334 VXNlcm5hbWU6
SMTP>> *
SMTP<< 500 5.5.1 Invalid command
SMTP>> QUIT
SMTP(close)>>
Transport port=25 replaced by host-specific port=2525
Connecting to smtp.mailgun.org [**.**.**.***]:2525 ... connected
SMTP<< 220 ak47 ESMTP ready
SMTP>> EHLO instance-1
SMTP<< 250-ak47
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-SMTPUTF8
250 STARTTLS
SMTP>> STARTTLS
SMTP<< 220 2.0.0 Start TLS
SMTP>> EHLO instance-1
SMTP<< 250-ak47
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-ENHANCEDSTATUSCODES
250 SMTPUTF8
SMTP>> AUTH LOGIN
SMTP<< 334 VXNlcm5hbWU6
SMTP>> *
SMTP<< 500 5.5.1 Invalid command
SMTP>> QUIT
SMTP(close)>>
Transport port=25 replaced by host-specific port=2525
Connecting to smtp.mailgun.org [**.**.**.***]:2525 ... connected
SMTP<< 220 ak47 ESMTP ready
SMTP>> EHLO instance-1
SMTP<< 250-ak47
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-SMTPUTF8
250 STARTTLS
SMTP>> STARTTLS
SMTP<< 220 2.0.0 Start TLS
SMTP>> EHLO instance-1
SMTP<< 250-ak47
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-ENHANCEDSTATUSCODES
250 SMTPUTF8
SMTP>> AUTH LOGIN
SMTP<< 334 VXNlcm5hbWU6
SMTP>> *
SMTP<< 500 5.5.1 Invalid command
SMTP>> QUIT
SMTP(close)>>
LOG: MAIN
== *********@gmail.com R=mailgun T=mailgun_transport defer (-42): authentication required but authentication attempt(s) failed
Best Answer
By working off of the Answer by Caracos(which I tried but couldn't get working) I was able to find this forum post and after modifying the details for Mailgun its working like a charm. I also like this solution because it is scalable to other mail relay services if needed.
https://forums.cpanel.net/threads/how-to-send-email-from-different-domains-using-different-smarthosts.641949/
I'll just outline the settings I used for Mailgun but refer to the link for more detailed explanations, pictures and other examples like Sendgrid, Mailjet and Sendpulse.
(Probably a good idea to backup settings before making these changes)
Section: AUTH
Section: PREROUTERS
Section: TRANSPORTSTART
Scroll to the bottom of the page and Save the Exim configuration and make sure Exim restarts.
This is some example data, change the domain, user and pass.
The 3rd example uses domain2.com credentials for domain3.com, this will work but the emails will include a via mg.domain2.com
Now email sent out from cPanel created email accounts on their respective domains will be intercepted by exim (allowed to connect to external SMTP servers) and relayed through Mailgun if the credentials in /etc/exim_smarthosts are correct and DNS settings are correct. However the WHM security settings still restrict all cPanel accounts from connecting to any external SMTP service so we need to do one more step to utilize the above setup for app based emailing.
To send email from Joomla, Wordpress or other CMS or App follow the next steps
a) Create an email account in cPanel and get the secure login credentials.
cPanel >> Email Accounts >> (New Email) >> Connect Devices >> Set Up Email Client
b) Use this Username, Password and Outgoing Server details in your Joomla, WordPress or other CMS/App/Plugin
Now your CMS's, plugins and apps are only connecting to an internal SMTP account but when that account sends out it is relayed through the external SMTP setup in the first steps.
BIG THANKS to DigitalComunic on cPanel forums whose diligent work and troubleshooting has given us a robust workaround that should be useful for years to come!!