Skip to main content

SmartHost (MailGun) - Specify AUTH for some domains and the rest default.

Comments

6 comments

  • cPRex Jurassic Moderator
    Hey there! I'm not sure there is going to be a way to do that without some manual intervention. While this is a bit outside the scope of cPanel, this post gets referenced a lot for this type of work, and is still valid today:
    0
  • cyben76
    Hey there! I'm not sure there is going to be a way to do that without some manual intervention. While this is a bit outside the scope of cPanel, this post gets referenced a lot for this type of work, and is still valid today:
    0
  • cPRex Jurassic Moderator
    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
  • cyben76
    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
  • cyben76
    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: AUTH mailgun_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: 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
    # /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_password2
    0
  • cPRex Jurassic Moderator
    Thanks so much for posting that!
    0

Please sign in to leave a comment.