Send specific sender domains through external SMTP

Murfy

Verified User
Joined
Jan 4, 2015
Messages
5
I would like to have e-mail from specific users being sent through an external SMTP.

For example a customer uses the PHP mail() function to send mass e-mails, so I would like to have all e-mail originating from that domain being relayed through e.g. Amazon SES or another better suited SMTP server.

How could I make this happen?
 
Hello,

Create your own router under section routers in /etc/exim.conf and check sending domain, something like this:

Code:
lookuphost:
  driver = dnslookup
  domains = ! +local_domains
  senders = ! *@domain.com
  ignore_target_hosts = 127.0.0.0/8
  condition = "${perl{check_limits}}"
  transport = remote_smtp
  no_more


# RELATED: http://help.directadmin.com/item.php?id=153
smart_route:
   driver = manualroute
   domains = ! +local_domains
   senders = *@domain.com
   ignore_target_hosts = 127.0.0.0/8
   condition = "${perl{check_limits}}"
   route_list = !+local_domains 11.22.33.44::25025
   transport = remote_smtp

this is a cut-off from my config. I'm not sure whether or not it includes all what you need. I could create and test a config for you in terms of a commerce service.
 
Using http://help.directadmin.com/item.php?id=153 is the preferable way, as you should not worry about keeping /etc/exim.conf up to date.

seems this guide isn't working with Amazon SES SMTP and exim mainlog isn't giving much info to go on ?
2019-07-27 12:25:18 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1hrSJi-0004Ct-Ry
2019-07-27 12:25:19 1hrSJi-0004Ct-Ry H=email-smtp.us-east-1.amazonaws.com [52.54.1.156]: SMTP error from remote mail server after ****************************************************************************************: 334 UGFzc3dvcmQ6
2019-07-27 12:25:20 1hrSJi-0004Ct-Ry H=email-smtp.us-east-1.amazonaws.com [52.4.127.249]: SMTP error from remote mail server after ****************************************************************************************: 334 UGFzc3dvcmQ6

config files looking pretty close to https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-exim.html as well

/etc/exim.transports.pre.conf
Code:
auth_relay:
    driver = smtp
    port = 587
    hosts_require_auth = $host_address
    hosts_require_tls = $host_address

/etc/exim.authenticators.post.conf
Code:
auth_login:
    driver = plaintext
    public_name = LOGIN
    #replace your@email and yourpass
    hide client_send = : YOUR_SES_SMTP_Username YOUR_SES_SMTP_Password

/etc/exim.routers.pre.conf
Code:
smart_route:
     driver = manualroute
     domains = ! +local_domains
     ignore_target_hosts = 127.0.0.0/8
     condition = "${perl{check_limits}}"

     #use remote_smtp only if you do not need smtp-auth.
     #transport = remote_smtp

     #use auth_relay if you do need to set the remote smtpauth
     transport = auth_relay

     route_list = * email-smtp.us-east-1.amazonaws.com::587
     no_more
 
Last edited:
Ah found the problem pesky missing semi-colon after sed replacement between username and password !
Code:
    hide client_send = : YOUR_SES_SMTP_Username YOUR_SES_SMTP_Password
should be
Code:
    hide client_send = : YOUR_SES_SMTP_Username : YOUR_SES_SMTP_Password
 
I believe for Amazon to work here you need to authenticate your domains, don't you?

And I use additional condition check, something like:

Code:
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_relay_remote}{yes}}
 
I believe for Amazon to work here you need to authenticate your domains, don't you?

And I use additional condition check, something like:

Code:
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_relay_remote}{yes}}

didn't need the additional condition check myself with Amazon SES but yes authenticated/verify domains and emails first on AWS Console is a must
 
the additional check is required if one needs to address the statement "I would like to have e-mail from specific users being sent through an external SMTP."
 
the additional check is required if one needs to address the statement "I would like to have e-mail from specific users being sent through an external SMTP."

Ah i see thanks for the clarification :)
 
Back
Top