Route all outgoing emails to another cPanel server

MaRiOsGR66

Well-Known Member
Feb 18, 2011
112
1
68
cPanel Access Level
Root Administrator
I have a cpanel server of which's ip is blocked currently by yahoo,
and another cpanel server which's ip is clear,
I would like to do the modifications needed in exim to route all outgoing email to the 2nd cpanel server (just like you do it with Sendgrid)
but I don't know how.

Any help?
 

dalem

Well-Known Member
PartnerNOC
Oct 24, 2003
2,983
159
368
SLC
cPanel Access Level
DataCenter Provider
this should work adding to exim advanced editor

------------------------------------------------------------------------

Section: AUTH

Smarthost_login:
driver = plaintext
public_name = LOGIN
hide client_send = : somesmtpuser : password


Section: ROUTERSTART

smarthost:
driver = manualroute
domains = ! +local_domains
transport = smarthost_transport
route_list = * hostname.otherserver.com::587 randomize byname
host_find_failed = defer
no_more


Section: TRANSPORTSTART

smarthost_transport:
driver = smtp
hosts = hostname.otherserver.com
hosts_require_auth = hostname.otherserver.com
hosts_require_tls = hostname.otherserver.com

# DKIM Settings
dkim_domain = ${lc:$sender_address_domain}
dkim_selector = default
dkim_private_key = "/var/cpanel/domain_keys/private/${dkim_domain}"
dkim_canon = relaxed
 
Last edited:

MaRiOsGR66

Well-Known Member
Feb 18, 2011
112
1
68
cPanel Access Level
Root Administrator
I did try it and immediately I was getting the error:

2020-03-09 13:49:07 1jBGXc-004acz-TM == info@******.gr R=smarthost defer (-30): transport "smarthost_transport" not found in smarthost router
2020-03-09 13:49:07 1jBGnn-004fTl-7x == grammateia@*****.gr R=smarthost defer (-30): transport "smarthost_transport" not found in smarthost router
2020-03-09 13:49:07 1jBGXd-004adC-EY == e*****@*****.com R=smarthost defer (-30): transport "smarthost_transport" not found in smarthost router
 

HostNoc

Well-Known Member
Feb 20, 2020
157
38
28
Ontario
cPanel Access Level
Root Administrator
Please add following in your exim configuration

smarthost_dkim:
driver = manualroute
domains = !"+local_domains +smart_hosts"
condition = "${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}{$value}}}{}{false}{true}}"
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
headers_add = "${perl{mailtrapheaders}}"
require_files = "+/var/cpanel/domain_keys/private/${sender_address_domain}"
transport = remote_smtp_smart_dkim
route_list = !+local_domains "${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}}"

smarthost_regular:
driver = manualroute
domains = !"+local_domains +smart_hosts"
condition = "${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}{$value}}}{}{false}{true}}"
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
headers_add = "${perl{mailtrapheaders}}"
transport = remote_smtp_smart_regular
route_list = !+local_domains "${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}}"

#TRANSPORTSTART
sendbysmarthoststransport:
driver = smtp
port = ${extract{port}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}
hosts_require_auth = $host_address

remote_smtp_smart_dkim:
driver = smtp
#hosts_require_tls = *
interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{}}}{}}
helo_data = ${if exists {/etc/mailhelo}{${lookup{$sender_address_domain}lsearch*{/etc/mailhelo}{$value}{$primary_hostname}}}{$primary_hostname}}
dkim_domain = $sender_address_domain
dkim_selector = default
dkim_private_key = "/var/cpanel/domain_keys/private/${dkim_domain}"
dkim_canon = relaxed

remote_smtp_smart_regular:
driver = smtp
#hosts_require_tls = *
interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{}}}{}}
helo_data = ${if exists {/etc/mailhelo}{${lookup{$sender_address_domain}lsearch*{/etc/mailhelo}{$value}{$primary_hostname}}}{$primary_hostname}}

If you still having issue then please share your exim configuration
 

dalem

Well-Known Member
PartnerNOC
Oct 24, 2003
2,983
159
368
SLC
cPanel Access Level
DataCenter Provider
had a typo in
smarthost_transport:

corrected in post above to fix "smarthost_transport" not found"

tested on one of my own servers & works
 
  • Like
Reactions: MaRiOsGR66

dalem

Well-Known Member
PartnerNOC
Oct 24, 2003
2,983
159
368
SLC
cPanel Access Level
DataCenter Provider
Updated
Added DKIM to Section: TRANSPORTSTART to pass dkim
Dont forget to add SPF

Note: we use this config on Our servers it works without issue
Note: you may need to tweak your settings

Note: had to modify Section: TRANSPORTSTART to pass dkim our mail server is stand alone ( no cpanel) & the dkim is passed from there so insure that it passess it correctly make mods as necesssary
 
  • Like
Reactions: MaRiOsGR66