Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Forward certain domain emails to Smart Host

Discussion in 'E-mail Discussion' started by Provim, Oct 27, 2009.

  1. kissmathis

    kissmathis Registered

    Joined:
    Mar 2, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    THis is my first post. I got an SMTP.COM account and I want all my mails to route through them as a smarthost. However they require smtp authentication, so far I know how to relay mail to their server but not how to authenticate it.
     
  2. William894

    William894 Registered

    Joined:
    Aug 30, 2012
    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    1
    Location:
    Bloemfontein, Free State, South Africa
    cPanel Access Level:
    Root Administrator
    Good Day,

    I am trying to setup routing for only outbound emails for a single domain on a shared hosting environment using exim for emails (obviously).

    The emails are to be filtered through a service called/with mimecast and I have managed to have the inbound emails filtered to their servers and then sent to the hosting server without any problems however I have tried the configuration I quoted below which created an infinite loop between mimecast and the hosting server causing the emails to be rejected and the outbound emails still was not sent via the mimecast service.

    I have also tried the following 2 pieces of code that have failed to have the outbound mail sent to the mimecast server to be sent out:

    Code:
    smart_route:
        driver = manualroute
        domains = !+local_domains
        transport = remote_smtp
        route_data = ${lookup{$domain}lsearch{/etc/staticroutes}}
    and

    Code:
     smart_route:
      driver = manualroute
      domains = domain.tld //obviously removed the domain address
      transport = remote_smtp
      route_list = * mail74.example.co.za
    The remote server with example has been setup to accept connections from the server via port 25 which I have tested through telnet.

    If anyone has had to setup the same thing and could let me know where I am going wrong and/or point me in the right direction that would be great.

    Thank you
     
    #22 William894, Sep 4, 2012
    Last edited: Sep 4, 2012
    HHaaland likes this.
  3. sneader

    sneader Well-Known Member

    Joined:
    Aug 21, 2003
    Messages:
    1,161
    Likes Received:
    49
    Trophy Points:
    178
    Location:
    La Crosse, WI
    cPanel Access Level:
    Root Administrator
    I'd love to help, but I really have no idea what you are trying to do. Perhaps if you were more detailed on how you expect a message to be routed, like so:

    1) Person at AOL sends mail to user@domain.tld.
    2) MX record for domain.tld points to mail74.mimecast.co.za so message is send to that server.
    3) mail74.mimecast.co.za filters the message, then sends the message to our hosting server.
    4) Our server then has a static route to route the message to ????

    If you spell it out like this, it should be more clear, and I, or someone, can help.

    - Scott
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. William894

    William894 Registered

    Joined:
    Aug 30, 2012
    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    1
    Location:
    Bloemfontein, Free State, South Africa
    cPanel Access Level:
    Root Administrator
    Good Day,

    I thought there might be a bit of confusion so here is the simple explanation.

    - Emails/Email addresses for domain.tld are hosted on on "shared server x"
    - The mx records for domain.tld is set to point to mail74.example.com so all emails are sent there and their server then hands the emails off to "shared server x" so that the users can download the emails from the server
    (So far this is working without any problems by keeping the domain in the local domains list so that the "shared server x" doesn't send the emails to the mx records)

    - Outbound emails for domain.tld are sent to "shared server x" which then needs to hand off the emails to mail74.example.co.za to send out to the world.

    I sent an email on the exim mailing list and got the following suggestion back:
    Code:
    smarthost:
      driver = manualroute
      domains = !+local_domains
      route_data = mail74.example.co.za
      transport = remote_smtp
      no_more
    This did route the outbound emails to mail74.example.co.za however it routed the emails for all domains on the server and not just the emails for domain.tld

    In short it should be working like this:
    INBOUND
    World -> mail74.example.co.za -> "Shared Server X" -> Email User (This works)

    OUTBOUND
    Email User -> "Shared Server X" -> mail74.example.co.za -> World (This is currently not working)
     
    #24 William894, Sep 7, 2012
    Last edited: Sep 7, 2012
  5. lockefaltaba

    lockefaltaba Member

    Joined:
    Oct 24, 2012
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi tristan, I have a recent post asking for this same thing .... I think (http://forums.cpanel.net/f43/smarthost-all-but-dedicated-ips-315991.html#post1297251)

    But in my case, the domains which should not be routed through the SmartHost are lots of them, and the ones to be routed through the dedicated IP they have are much less. So what would be the way to set this kinda "exclude this ones from routing thru the SmartHost" ??
     
  6. jsilvestre

    jsilvestre Member

    Joined:
    Jul 7, 2005
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    151
    Hello Guys,

    regarding this topic... We are testing a Comodo Antispam Gateway in a bunch of servers. The configuration that we are using is from their kb <http://help.comodo.com/topic-157-1-288-4545-configuring-exim---cpanel-to-use-a-smarthost.html>.

    This servers have a few IPs and 200 domains (some of them with dedicated IP for web and mail). However i just want give this service "as trial" for some customers. How can i make a condition to just relay if based on mailips, match with one or more IPs (xxx.xxx.xxx.6) or based on interface (eth0 , eth0:1, etc)

    E.g (/etc/mailips)

    domain1:xxx.xxx.xxx.1
    domain2:xxx.xxx.xxx.2
    domain3:xxx.xxx.xxx.3
    domain4:xxx.xxx.xxx.4
    domain5:xxx.xxx.xxx.5
    *:xxx.xxx.xxx.6

    Looking for your feedback.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. gatorregesdahl

    gatorregesdahl Registered

    Joined:
    Apr 27, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    I know this is a rather old thread, but I wanted to let everyone know I have managed to come up with an Exim router configuration that works to forward only mail from certain configured domains to a smarthost, just in case anyone needed it or if the Powers That Be wanted to use it for something. Here it is:

    First, put this in the @CONFIG@ section of /etc/exim.conf.local:
    Code:
    hostlist smart_hosts = lsearch;/etc/smarthosts
    Then, put this in @ROUTERSTART@:
    Code:
    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 : 64.94.110.0/24
      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 : 64.94.110.0/24
      headers_add = "${perl{mailtrapheaders}}"
      transport = remote_smtp_smart_regular
      route_list = !+local_domains "${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}}"
    Then, this in @TRANSPORTSTART@:
    Code:
    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}}
    Make sure /etc/staticroutes and /etc/smarthosts exists and run /scripts/buildeximconf to regenerate the configuration. To actually use it, add the smarthost domain name to /etc/smarthosts and a line like this (per domain) to /etc/staticroutes:
    Code:
    domain.com: smarthost.com
    The domains can do partial matching, so something like this will also work:
    Code:
    *.sub.domain.com: smarthost.com
    This does not do authentication yet, so be forewarned that you will need more modifications if you need that. I hope this helps someone out there!
     
  8. bobster

    bobster Registered

    Joined:
    Mar 4, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Just want to thank Gatorregesdahl, your post worked perfectly!!

    for those that also need this. I had to make to obvious modifications:

    Modification1
    change:
    ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 64.94.110.0/24
    to:
    ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : your.server.ip

    Modification 2:
    if TLS is not setup simply remove this line in @TRANSPORTSTART@:
    hosts_require_tls = *

    obviously TLS is recommented!
     
  9. imageinabox

    imageinabox Member

    Joined:
    Nov 20, 2013
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Huntsville, AL
    cPanel Access Level:
    Root Administrator
    Twitter:
    Just added this in and it works great!!
     
  10. SB-Nick

    SB-Nick Well-Known Member

    Joined:
    Aug 26, 2008
    Messages:
    175
    Likes Received:
    9
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    The workaround from above won't work if a cPanel account has a forwarder setup on their account.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. cliper

    cliper Registered

    Joined:
    May 2, 2014
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    76
    cPanel Access Level:
    Root Administrator
    Just want to make sure. Did gatorregesdahl solution solves this example?

    outbound1-certain-domains.com => Amazon SES
    outbound2-common.com => from host (local server)


    What I'd like to accomplish is to be able to send e-mails from

    outboud1.com using Amazon SES through SMTP. There would be specific domains of this.

    and also, for those domains that are not listed should use the default outbound route which is the server itself.

    can someone confirm this? thanks!
     
  12. hlastimosa

    hlastimosa Member

    Joined:
    Aug 6, 2014
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Does this work even if you do not have a dedicated IP from your smarthost (e.g. MailChimp)

    I have tried gatorregesdahl's steps above with the following configuration

    1. /etc/smarthosts

    domain1.tld: smtp.mandrillapp.com

    2. /etc/staticroutes
    domain1.tld: smtp.mandrillapp.com

    and Getting the rest of the configuration to the specific routers indicated.
    After restarting Exim , it would error out and say "unroutable address"

    Do I need to add and MX record for the domain in the /etc/smarthosts and point it to mandrilla?

    Thank you!
     
  13. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Could you let us know the the specific error message you noticed?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. dr_lucas

    dr_lucas Well-Known Member

    Joined:
    Jul 6, 2007
    Messages:
    47
    Likes Received:
    1
    Trophy Points:
    58
    Location:
    Thailand
    What's the solution/workaround in case the account has forwarders?
     
  15. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. feanorknd

    feanorknd Member

    Joined:
    Sep 28, 2005
    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    153
    Helo:

    I will share my easy way to use mandrill smarthost only for one domain at cpanels server.


    Section: AUTH

    mandrilldomain1:
    driver = plaintext
    public_name = LOGIN
    hide client_send = : <MANDRILL_SMTP_LOGIN> : <MANDRILL_SMTP_API_KEY>


    Section: PREROUTERS (attention to <my_domain>, is just mydomain.tld)

    mandrilldomain1router:
    driver = manualroute
    domains = ! +local_domains
    condition = "${if eq {$sender_address_domain}{<my_domain>}{true}{false}}"
    ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 64.94.110.0/24
    headers_add = "${perl{mailtrapheaders}}"
    transport = mandrilldomain1transport
    route_list = * smtp.mandrillapp.com


    Section: TRANSPORTSTART

    mandrilldomain1transport:
    driver = smtp
    port = 587
    hosts_require_auth = $host_address
    hosts_require_tls = $host_address


    And that is all..... the router will route outgoing mails from only my_domain (mydomain.tld), using AUTH, to mandrill transport.


    Regards!
     
  17. Azim

    Azim Well-Known Member

    Joined:
    Oct 16, 2015
    Messages:
    64
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    India
    cPanel Access Level:
    Website Owner
    Hello,
    Thanks for your link and it seems it is quit difficult. Could you please help me how can I add multiple senders in below route,
    #smarthost_App:
    #driver = manualroute
    # domains = !+local_domains
    # senders = !*@domain1.com
    # # Exclude null sender messages from relaying via the smarthost
    # condition = ${if or {{!eq{$sender_address}{}} {!eq{$sender_host_address}{}}}}
    # transport = remote_smtp_smart_gapp
    # route_list = * smtp-relay.gmail.com

    Can I use senders = !*@domain1.com;!*@domain2.com

    Will multiple sender works ? Should I separate them using semi colon.

    It would be really helpful if you could help me to modify the smarthost as per my requirement.
     
  18. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Could you review Post 27 and Post 28 of this thread and let us know if those steps work on your system? If not, could you let us know which step you are stuck with? Note you may find the following document helpful for background knowledge on editing the Exim configuration:

    How to Edit the /etc/exim.conf File

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice