The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Use Exim smarthost for only single email address

Discussion in 'E-mail Discussions' started by dr_lucas, Mar 23, 2016.

  1. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    I have configured Exim to send email using gmail's SMTP through the smarthost.
    The problem is that gmail rewrites the sender of all the emails that are going through its SMTP to be the same as the gmail account so if someone send us an email from user@somewhere.com, we receive it with the sender ouraccount@gmail.com

    How can I setup Exim to use the smarthost only for a single email address so that if an email from anyone other than that address are being processed by Exim it will use the standard Exim configuration as if there is no smarthost and if there is an email being sent by either our email client or the server that uses ouraccount@gmail.com, it will be processed by the smarthost?

    This is my ADVANCED configuration (note that OURACCOUNT and OURPASSWORD are obviously replaced with our gmail username and password):

    Section: AUTH

    gmail_login:
    driver = plaintext
    public_name = LOGIN
    client_send = : OURACCOUNT@gmail.com : OURPASSWORD


    Section: ROUTERSTART

    send_via_gmail:
    driver = manualroute
    domains = ! +local_domains
    transport = gmail_smtp
    route_list = * smtp.gmail.com



    Section: TRANSPORTSTART

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


    In my BASIC configuration I have setup the smarthost to be:
    * smtp.gmail.com


    Thank you
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    There's a thread on this at:

    Forward certain domain emails to Smart Host

    Thank you.
     
  3. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Yes, I have read that thread, but it discusses sending whole domain emails to smarthost.
    I need to know hot set it up to send only 1 specific email address of a domain to smarthost, not all the domain's email addresses.

    Thank you
     
  4. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Yes, that thread suggests adding
    local_parts= user

    Does that mean that if I want, for example, to use the smarthost only for info@ourdomain.com and process normally without smarthost all other emails, I should rewrite my configuration to be:

    send_via_gmail:
    driver = manualroute
    domains = ! +local_domains
    local_parts= user
    transport = gmail_smtp
    route_list = * smtp.gmail.com

    OR

    send_via_gmail:
    driver = manualroute
    domains = ! +local_domains
    local_parts= info@ourdomain.com
    transport = gmail_smtp
    route_list = * smtp.gmail.com

    OR

    send_via_gmail:
    driver = manualroute
    domains = ourdomain.com
    local_parts= user
    transport = gmail_smtp
    route_list = * smtp.gmail.com

    OR

    send_via_gmail:
    driver = manualroute
    domains = ourdomain.com
    local_parts= info
    transport = gmail_smtp
    route_list = * smtp.gmail.com


    Or something else?
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I've looked through the following document from Exim:

    20. The manualroute router

    From what I understand, it should look like this:

    Code:
    send_via_gmail:
       driver = manualroute
       domains = ! +local_domains
       senders = user@example.tld
       transport = gmail_smtp
       route_list = "* smtp.gmail.com"
    
    Note that some users choose to add additional values such as "host_find_failed = defer" to keep messages in the queue if the remote mail server is unresponsive.

    I've found the best way to understand the smart host configurations with Exim is to go line by line and research to see what each value means. For instance, local_domains might not make much sense on it's own, but if you search for it in /etc/exim.conf you see an entry such as:

    Code:
    domainlist local_domains = lsearch;/etc/localdomains
    Thus, you can infer it's referring to any domain name in the /etc/localdomains file on the server. The "!" symbol is used to negate items. So, when we see this:

    Code:
    domains = ! +local_domains
    It's negating this manual route for all domain names in /etc/localdomains, so that it only applies to a specific sender that's defined on the next line.

    Thank you.
     
  6. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Thanks. Just to clarify, as I am not sure what user@example.tld in your code means

    You mean I should set it up like this?

    Code:
    send_via_gmail:
       driver = manualroute
       domains = ! +local_domains
       senders = info@ourdomain.com
       transport = gmail_smtp
       route_list = "* smtp.gmail.com"
       host_find_failed = defer
    
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Yes, in your case it would be "info@ourdomain.com". I've also edited the previous post with some additional information.

    Thank you.
     
  8. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Bravo! Seems to work! :)
    Thanks, Michael!
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  10. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Just curios.
    You wrote:
    So what happens when there are no list of senders in the next line, as in my original example:
    Code:
    Section: ROUTERSTART
    
    send_via_gmail:
    driver = manualroute
    domains = ! +local_domains
    transport = gmail_smtp
    route_list = * smtp.gmail.com
    
    
     
  11. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    The expected behavior is that no email accounts or domain names would use that smart host.

    Thank you.
     
  12. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    But what actually happens is that all email accounts and domains use the smart host.
     
  13. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Could you elaborate on all custom entries you are utilizing with Exim? For instance, is that the only change you have made to the Exim configuration for email routing?

    Thank you.
     
  14. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Yes, Michael, the configuration in the OP is the only configuration change I have made for email routing.
    You can test this yourself, I am sure you will see the same results.
     
  15. dr_lucas

    dr_lucas Active Member

    Joined:
    Jul 6, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Seems I was wrong.
    The suggested setup didn't work properly.
    All emails from info@ourdomain.com did go through fine.
    However, all other emails sent to our domain email addresses or from other email addresses on our domain got routed through the smarthost and rejected. :(
    Any other suggestions?
     
  16. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page