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!

SOLVED Exim Deny All Except

Discussion in 'E-mail Discussion' started by vponteras, Mar 8, 2018.

Tags:
  1. vponteras

    vponteras Member

    Joined:
    May 16, 2017
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Philippines
    cPanel Access Level:
    Root Administrator
    Hi All,

    I want outgoing messages for our domain (our-domain.com) blocked except for other other domains. I tried the suggested exim filter from cPanelMichael but it's not working.

    I want our-domain to blocked from all domains but still can send to our-domain.com, allowed1.com and allowed2.com

    Here is my exim filter

    Code:
    if
      $header_from: contains "@our-domain" and
      $header_to: does not contain "@out-domain" or
      $header_to: does not contain "@allowed1.com" or
      $header_to: does not contain "@allowed2.com"
    then
      fail text "Unauthorized Mail"
    endif
    
    Please help
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,940
    Likes Received:
    1,819
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you also outline the specific steps you have taken thus far to implement that custom filter rule?

    Note the email filter options in cPanel are designed to filter incoming email. You can customize the Exim system filter if you want to apply a filter to outgoing email. Information about modifying the Exim system filter is documented at:

    How to Customize the Exim System Filter File - cPanel Knowledge Base - cPanel Documentation

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

    vponteras Member

    Joined:
    May 16, 2017
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Philippines
    cPanel Access Level:
    Root Administrator
    Hi cPanelMichael,

    I am using the system filter /etc/cpanel_exim_system_filter_custom.

    I want block all incoming and outgoing mails except for our domain, allowed1.com and allowed2.com.

    Because we're planning to have our mails for company mails only and prevent incoming mails except for allowed1.com and allowed2.com

    What should be the suitable filter for that setup?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,940
    Likes Received:
    1,819
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    The rules in your initial post look okay. 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. vponteras

    vponteras Member

    Joined:
    May 16, 2017
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Philippines
    cPanel Access Level:
    Root Administrator
    I am already using our custom filter
     

    Attached Files:

    #5 vponteras, Mar 8, 2018
    Last edited: Mar 9, 2018
  6. vponteras

    vponteras Member

    Joined:
    May 16, 2017
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Philippines
    cPanel Access Level:
    Root Administrator
    Hi, anybody can help?
     
  7. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    694
    Likes Received:
    233
    Trophy Points:
    93
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    In a normal account filter rule, the 'or' operator does not work using <does not contain>. I don't know about the custom rules for exim outgoing mail, but you could have a look at SOLVED - Account level filter "or" failing to see if it might be of any help.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. vponteras

    vponteras Member

    Joined:
    May 16, 2017
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Philippines
    cPanel Access Level:
    Root Administrator
    Hi,

    This seems to work for me

    Code:
    if (
      $h_to: does not contain "our-domain.com" and
      $h_to: does not contain "allowed-domain1.com" and
      $h_to: does not contain "allowed-domain2.com" and
      $h_to: does not contain "allowed-domain3.com" and
      $h_to: does not contain "allowed-domain4.com"
      )
      and
      ($h_from: contains "our-domain.com")
    then
      fail text "Unauthorized Mail"
    endif
    
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,940
    Likes Received:
    1,819
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm glad to see you found a suitable filter rule. Thank you for sharing the outcome.
     
    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