How To: Setup SMTP Relay and Follow Max Hourly Mail Limits
To setup a remote smtp relay with authentication that will adhere to and follow your max hourly mail limits we will make a slight change to this process as in the previous forum article on creating an smtp relay with authentication.
First login to WHM and then proceed to the following location Home "Service Configuration "Exim Configuration Manager and click the Basic Editor tab.
From here search for Smarthost Support under the Mail tab. Enter your smart host as follows. Please note the space between the * (asterisk) and hostname. Then hit save.
Next go to the Advanced Editor Tab and look for each of the sections below and enter the information below that section into the corresponding boxes in the configuration editor. Make sure to update this information with your smtp server, username and password. Section: POSTMAILCOUNT The POSTMAILCOUNT section must be used instead of ROUTERSTART if you wish for max hourly mail limits to be followed and used. You must also add the domains = section if you wish for the server to still accept mail for the localdomains and only relaying mail out. Otherwise all email, incoming and outgoing gets relayed.
Section: TRANSPORTSTART
Section: AUTH
If you wish to use DKIM from the Server add the following to each section as well. Section: POSTMAILCOUNT
Section: TRANSPORTSTART
Once you have finished adding the above to all the appropriate sections, simply scroll to the bottom of the page and click save. It will automatically apply the settings and restart exim. Now anytime you send mail out it will be routed out through the remote smtp relay and will continue to follow your max hourly mail limits. If you have any issues or questions with this feel free to open a ticket.
* my.smarthost.com
Next go to the Advanced Editor Tab and look for each of the sections below and enter the information below that section into the corresponding boxes in the configuration editor. Make sure to update this information with your smtp server, username and password. Section: POSTMAILCOUNT The POSTMAILCOUNT section must be used instead of ROUTERSTART if you wish for max hourly mail limits to be followed and used. You must also add the domains = section if you wish for the server to still accept mail for the localdomains and only relaying mail out. Otherwise all email, incoming and outgoing gets relayed.
remoteserver_route:
driver = manualroute
transport = remoteserver_relay
domains = !+local_domains
route_list = * smtp.server.com
Section: TRANSPORTSTART
remoteserver_relay:
driver = smtp
port = 587
hosts_require_auth = $host_address
hosts_require_tls = $host_address
Section: AUTH
remoteserver_login:
driver = plaintext
public_name = LOGIN
hide client_send = : user@domain.com : password
If you wish to use DKIM from the Server add the following to each section as well. Section: POSTMAILCOUNT
smarthost_dkim:
driver = manualroute
domains = !+local_domains
require_files = "+/var/cpanel/domain_keys/private/${sender_address_domain}"
transport = remote_smtp_smart_dkim
route_list = * smtp.domain.com
Section: TRANSPORTSTART
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
Once you have finished adding the above to all the appropriate sections, simply scroll to the bottom of the page and click save. It will automatically apply the settings and restart exim. Now anytime you send mail out it will be routed out through the remote smtp relay and will continue to follow your max hourly mail limits. If you have any issues or questions with this feel free to open a ticket.
-
Great tutorial. Scenario: You have multiple cPanel accounts... Some domains use the remote Office365 Exchange platform, others use the cPanel email accounts... Do you have a way to set up a relay per account? The reason I ask is that I would like cPanel/SpamAssassin to be able to scan an email before relaying it further, whilst holding the capability of using a local mail exchange OR a remote mail exchanger. Peter 0 -
Hi, The following article may be of some help with this. This will allow you to set up a relay on a per domain basis. Unfortunately there is no way to do this per cPanel account level however. In summary it looks like you need to add the following to POSTMAILCOUNT if you plan to only relay for specific domains. remoteserver_route: driver = manualroute transport = remoteserver_relay domains = !"+local_domains +smart_hosts" condition = "${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}{$value}}}{}{false}{true}}" route_list = !+local_domains "${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}}"
You would also want to add the following to the CONFIG section by clicking "Add additional configuration setting" and then using the following.hostlist smart_hosts = lsearch;/etc/smarthosts
Then add your smart host to /etc/smarthostssmtp.domain.com
Followed by the domains you wish to relay here. You can also specify wildcards.mydomain.com: smtp.domain.com *.mydomain.com: smtp.domain.com
This will only relay the domains in that file and everything else would send out through the server. You can also use this to relay certain domains through different servers. I have tested this and it seems to work fine. The forum article linked above looks to have additional configuration options which may be used but I do not see as being required.0 -
For the Smarthost Support under the Mail tab, you need to set it back to "default" to get delivery to domains not found in /etc/staticroutes via your server. Otherwise, after much reading, and thanks to this article and the links forum posts, I've got the smart host finally setup to work per domain with Mandrill. Tested and working, and now to monitor Exim's mail logs just to be sure. Thank you! 0 -
Hi Mat, I've try this but it doesnt work, this is the log on the server: I've already hit the MAIL tab and the smarthost on default values. 2015-09-16 16:03:32 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1Zc8cg-00087o-Su 2015-09-16 17:09:12 failed to expand condition "${if and{{bool_lax{NULL}}{bool_lax{${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}{$value}}}{}{false}{true}}}}}}" for remoteserver_route router: failed to open /etc/staticroutes for linear search: No such file or directory inside "and{...}" condition cat /etc/smarthosts domain.co.id: 202.1*4.1*.2 but none email relay to the server that I define on the smarthost Thank you! Hi, The following article may be of some help with this. This will allow you to set up a relay on a per domain basis. Unfortunately there is no way to do this per cPanel account level however. In summary it looks like you need to add the following to POSTMAILCOUNT if you plan to only relay for specific domains.
remoteserver_route: driver = manualroute transport = remoteserver_relay domains = !"+local_domains +smart_hosts" condition = "${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}{$value}}}{}{false}{true}}" route_list = !+local_domains "${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}}"
You would also want to add the following to the CONFIG section by clicking "Add additional configuration setting" and then using the following.hostlist smart_hosts = lsearch;/etc/smarthosts
Then add your smart host to /etc/smarthostssmtp.domain.com
Followed by the domains you wish to relay here. You can also specify wildcards.mydomain.com: smtp.domain.com *.mydomain.com: smtp.domain.com
This will only relay the domains in that file and everything else would send out through the server. You can also use this to relay certain domains through different servers. I have tested this and it seems to work fine. The forum article linked above looks to have additional configuration options which may be used but I do not see as being required.0 -
I believe they are deferred until said limits are lifted. (The next 200 would be sent after the hour) 0
Please sign in to leave a comment.
Comments
5 comments