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!

Restrict outgoing email to certain domains

Discussion in 'E-mail Discussion' started by mrasmith, Mar 20, 2018.

Tags:
  1. mrasmith

    mrasmith Member

    Joined:
    May 28, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    51
    Hi, I'm trying to restrict emails from my account (mydomain.com) and only allow users email addresses at mydomain.com and myotherdomain.com, with the exception of users john and david ..

    I've tried the code below with no luck, all emails fail !?

    I'm new to this and this is my first attempt so I apologise if I'm way off !

    Any help would be appreciated, thanks.

    Code:
    if first_delivery
       and ("$h_from:" contains "@mydomain.com")
       and ("$h_from:" does not contain "john@mydomain.com" or "$h_from:" does not contain "david@mydomain.com")
       and ("$h_to:, $h_cc:" does not contain "@mydomain.com" or "$h_to:, $h_cc:" does not contain "@myotherdomain.com")
    then
       fail "Cannot send to this recipient."
    endif
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,367
    Likes Received:
    1,857
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Can you confirm if you are attempting to filter outgoing email (e.g. mail sent FROM the cPanel server), incoming email, or both? What method did you use to setup the filter?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. mrasmith

    mrasmith Member

    Joined:
    May 28, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    51
    Hi, thanks for the reply.

    I'm trying to restrict outgoing email to be limited to sending to certain domains.

    I put the filter file above in /etc/cpanel_exim_customfilter and then pointed the 'system filter file' setting at this within the Exim Configuration Manager on WHM.

    Is there an easier way to achieve this ?

    Thanks again.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,367
    Likes Received:
    1,857
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    A custom Exim system filter rule is the correct approach when attempting to block outgoing email. Here are some threads with examples you may want to use when developing and testing your own custom rules:

    Blocking all cPanel users from emailing specific domains/email accounts
    Need to filter ALL email

    Also, in "WHM >> Exim Configuration Manager", under the "Filters" tab, are you using a custom filter for the "System Filter File" option? If so, you'd need to add your custom filter rules to that custom system filter file itself instead of adding them as separate filter files under the options directory. There's a thread on this topic at:

    Exim custom filter not working

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. mrasmith

    mrasmith Member

    Joined:
    May 28, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    51
    Yes I'm using a custom system filter file with my rules and have that file specified in the "System Filter File" option.

    Thanks, I'll have a look at those threads.
     
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