Skip to main content

How To: Setup SMTP Relay and Follow Max Hourly Mail Limits

Comments

5 comments

  • LostNerd
    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
  • cPMatthewV
    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/smarthosts
    smtp.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
  • Kurieuo
    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
  • akbardotinfo
    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/smarthosts
    smtp.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
  • LostNerd
    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.