4

Hello I have two (or maybe more later) domains:

domain1 domain2

I want to configure Exim (cPanel) to use SendGrid's or Mailgun SMTP servers, currently I'm trying with this config in Exim:

**Section: TRANSPORTSTART**
domain1_smtp:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org

domain2_smtp:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org


**Section: AUTH**
domain1_login:
driver = plaintext
public_name = LOGIN
client_send = : postmaster@mg.domain1.com : password

domain2_login:
driver = plaintext
public_name = LOGIN1
client_send = : postmaster@mg.domain2.com : password

**Section: PREROUTER**
send_via_domain1:
driver = manualroute
domains = ! +local_domains
senders = *@domain1.cm
transport = domain1_smtp
route_list = "* smtp.mailgun.org::2525 byname"
host_find_failed = defer

send_via_domain2:
driver = manualroute
domains = ! +local_domains
senders = *@domain2.com
transport = domain2_smtp
route_list = "* smtp.mailgun.org::2525 byname"
host_find_failed = defer

When I'm sending email from user@domain1.com I'm getting messages delivered by postmaster@mg.domain1.com and when I'm sending from user@domain2.com I'm getting messages delivered also from postmaster@mg.domain1.com.

I want to have smarthost for every domain with different credentials. Thanks

eXtreme
  • 244
  • 3
  • 18

1 Answers1

1

I have these setup (VPS + WHM/cPanel + Exim + Mailgun) and after doing some online research, I've found a few helpful websites regarding this topic and managed to come out with the correct configuration. Below are the solutions that I'm currently using on my VPS and hope it will help you as well. It should solve your "via" problem and might solve the intermittent "550 5.7.1 Relaying denied" error from Mailgun as well:



Go to the "Exim Configuration Editor" in WHM. Choose "Advanced Editor" and insert the configuration below:



Section: AUTH

mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = ": ${extract{login}{${lookup{$sender_address_domain}lsearch{/etc/exim_mailgun}{$value}fail}}} : ${extract{password}{${lookup{$sender_address_domain}lsearch{/etc/exim_mailgun}{$value}fail}}}"



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



Then create a file named /etc/exim_mailgun and insert the content similar to the structure below (Replace it with your Mailgun's domain login credentials that was verified):

domain1.com:    username=postmaster@mg.domain1.com     password=abcdefghi
domain2.com:    username=postmaster@mg.domain2.com     password=jklmnopqr
Caracos
  • 31
  • 5