SmartHost (MailGun) - Specify AUTH for some domains and the rest default.
Hi,
I'm using MailGun as a SmartHost with the following:
#Section: AUTH
#Section: ROUTERSTART
#Section: TRANSPORTSTART
#My /etc/exim_smarhosts
So the above is only for 2-3 domains that are in my /etc/exim_smarhosts how do I route all other domains on the server to another MailGun credential without manually adding the domains to /etc/exim_smarhosts, for example:
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : ${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}: ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}#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#My /etc/exim_smarhosts
domain1.com: domain=domain1.com user=MAILGUN_smtp_user1 pass=MAILGUN_api_password1
domain2.com: domain=domain2.com user=MAILGUN_smtp_user2 pass=MAILGUN_api_password2So the above is only for 2-3 domains that are in my /etc/exim_smarhosts how do I route all other domains on the server to another MailGun credential without manually adding the domains to /etc/exim_smarhosts, for example:
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : Default-SMTP-Login:Default-Password-
How ironic that you're getting bouncebacks from the Exim list... I couldn't find anything else on my end about this type of split delivery when I searched either, but it's always possible another user has configured this and will join in with their thoughts. 0 -
After going thru the Exim Documentation, this is what I came up with: mailgun_login: driver = plaintext public_name = LOGIN hide client_send = : ${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/exim_smarthosts}{$value}}}{}{DEFAULT_MAILGUN_SMTP_LOGIN : DEFAULT_MAILGUN_SMTP_PASS}{${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}{$value}fail}}} : ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}{$value}fail}}}}}
It works in Exim cli, but when I try sending an email I get an error. Most likely some syntax issues with regards to the colon:
, still can't figure it out. The:
is recognized as the start of a new string so it expects a}
to close the string. Adding double colon::
will result in Auth failure.0 -
Ok finally found out why I could not post to the Exim-users mailing list, I think it was because I used my work email. I registered with my Gmail account and was able to post a question. I'll post here so if anyone is looking for the same answer could find it. So this is what Jasen Betts from Exim-user: First Option: change lsearch to nwildlsearch add a * entry at the end of the /etc/exim_smarthosts file. that entry has the default credentials
Second Option:use the not-found branch of "lsearch" or "extract" to get the default credentials. which means code like: hide client_send = : \ ${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}{$value}{DEFAULTUSER}}}}:\ ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}{$value}{DEFAULRPASS}}}} or hide client_send = : \ ${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}{$value}{DEFAULTUSER}}:\ ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}{$value}{DEFAULRPASS}}
I went with the second option and it works perfectly! So my Exim config be like: #Section: AUTHmailgun_login: driver = plaintext public_name = LOGIN hide client_send = : \ ${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}{$value}{DEFAULTUSER}}:\ ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}{$value}{DEFAULRPASS}}
#Section: ROUTERSTARTmailgun: driver = manualroute domains = ! +local_domains transport = mailgun_transport route_list = "* smtp.mailgun.org::587 byname" host_find_failed = defer no_more
#Section: TRANSPORTSTARTmailgun_transport: driver = smtp hosts = smtp.mailgun.org hosts_require_auth = smtp.mailgun.org hosts_require_tls = smtp.mailgun.org
# /etc/exim_smarhostsdomain1.com: domain=domain1.com user=MAILGUN_smtp_user1 pass=MAILGUN_api_password1 domain2.com: domain=domain2.com user=MAILGUN_smtp_user2 pass=MAILGUN_api_password20 -
Thanks so much for posting that! 0
Please sign in to leave a comment.
Comments
6 comments