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.

Routing outgoing emails

Discussion in 'E-mail Discussions' started by gesman, May 7, 2013.

  1. gesman

    gesman Registered

    Joined:
    May 7, 2013
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello,

    I own dedicated server: Centos 6 + WHM where i host multiple sites. Many emails are just forwarded to related gmail accounts, such as:
    john@mysite1.com -> john123@gmail.com
    mary@mysite2.com -> mary345@gmail.com

    I want to route all outgoing emails (initiated via scripts on my sites, such as contact forms or password reset forms) via SendGrid/SMTP. Although I *do NOT* want to route all incoming emails (mostly incoming spam) via SendGrid.

    I followed this tutorial: /http://sendgrid.com/docs/Integrate/Mail_Servers/exim.html.
    But as a result of it - I have *ALL* emails (incoming and outgoing) going through SendGrid:
    - Gmail is forwarding emails from paypal.com to spam folder.
    - Every piece of spam is consuming my SendGrid quota now.

    What do I need to change to make sure that only outgoing emails initiated by my websites go through SendGrid?

    Gleb
     
    #1 gesman, May 7, 2013
    Last edited: May 7, 2013
  2. gesman

    gesman Registered

    Joined:
    May 7, 2013
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Ok, here's an answer. Took me 24 hours to dig for it.
    Put this into:
    WHM >> Home >> Service Configuration >> Exim Configuration Manager >> Advanced Editor
    "Section: ROUTERSTART" :
    Code:
    send_via_sendgrid:
      driver = manualroute
      domains = ! +local_domains
      condition = ${if match_domain{$sender_address_domain}\
                     {$primary_hostname : +local_domains}\
                     {yes}{no}}
      transport = sendgrid_smtp
      route_list = "* smtp.sendgrid.net::587 byname"
      host_find_failed = defer
      no_more
    
    This will allow you to use SendGrid only for outgoing emails originated by your website scripts, but *skip sendgrid* for all incoming emails, including emails that require subsequent forwarding outside.
    Thus saving your Sendgrid quota and essentially allowing you escape dedicated server IP blacklisting/whitelisting cat-n-mouse games.

    Here's what above will allow you to have:


    1. Sending email to outside from any domain on your dedicated server to be routed through Sendgrid:
    you@yoursite1.com --[SENDGRID SMTP]--> john.someone@yahoo.com

    2. Contact forms and scripts from your websites will route all emails through sendgrid:
    cpanel.account@your.site.primary.hostname.com --[SENDGRID SMTP]--> john.someone@yahoo.com

    3. Incoming, pre-authenticated (and spam) emails processed directly, without sendgrid:
    john.someone@yahoo.com -> you@yoursite1.com ---/*NO SENDGRID HERE*/--> your.email@gmail.com
    spammer@china.cn -> you@yoursite1.com ---/*NO SENDGRID HERE*/--> your.email@gmail.com

    In latter(spam) case - email might not even reach destination due to anti-spam measures.

    PS: You of course may use any other transactional email delivery service, not only SendGrid. Just change SMTP server address and credentials.

    Gleb
     
    #2 gesman, May 8, 2013
    Last edited: May 8, 2013
  3. zeta1600

    zeta1600 Member

    Joined:
    Mar 25, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    This was about the best help on this issue I've found. I was wondering if you would be willing to give a step by step to implement sendgrid. Like, I don't understand how and where to add things according to this page: https://sendgrid.com/docs/Integrate/Mail_Servers/exim.html
    How and where to add this?
    Also, it says: Add a route in the Router Configuration Box:? Which router box? ROUTERSTART, like your instruction above?
    And, it says: Add a transport to the Transport Configuration Box:? Which Transport box? TRANSPORTSTART?

    Any help would be greatly appreciated.
     
  4. zeta1600

    zeta1600 Member

    Joined:
    Mar 25, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    I got this to work... the first time I edited the file at WHM >> Home >> Service Configuration >> Exim Configuration Manager >> Advanced Editor, it created the file /etc/exim.conf.local. I then just edited the file to follow the instructions at: https://sendgrid.com/docs/Integrate/Mail_Servers/exim.html#-cPanel. You should begin there.

    I went to Edit MX Entry and added smtp.sendgrid.net has priority 0.

    This tutorial helped: Tutorial Of Administrator: Implementing SendGrid with Exim on cPanel

    I hope this helps someone.
     
  5. kgab0r

    kgab0r Registered

    Joined:
    Feb 10, 2014
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi.

    Is there any way to route just some domain over sendgrid?
     
Loading...

Share This Page