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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED How to block one email user from sending to certain domains?

Discussion in 'E-mail Discussions' started by bcadej, Apr 10, 2018.

Tags:
  1. bcadej

    bcadej Member

    Joined:
    Aug 20, 2015
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Slovenija
    cPanel Access Level:
    Root Administrator
    I have several domains on my WHM/cPanel server. These domains have several users (e.g. email addresses).


    I would like to block that from one MY email account cannot be send email to certain domains.


    Example:

    user1@mydomain.si – can send email to everybody

    user2@mydomain.si – can NOT send email to @gmail.com, @hotmail.com, @web.de but can send email to ALL other domains.


    I hope you understand my concern.


    Thank you for your help.


    Best regards,

    Bostjan
     
    Tarak Nath likes this.
  2. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    372
    Likes Received:
    21
    Trophy Points:
    93
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
  3. bcadej

    bcadej Member

    Joined:
    Aug 20, 2015
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Slovenija
    cPanel Access Level:
    Root Administrator
    I don't want to mess up stuff. I'm not experienced script user.

    That example shows hot to block receiving mail from user@example.com.

    What to write to meet my needs.

    Block mail TO certain domains FROM one local user – email?
     
  4. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    372
    Likes Received:
    21
    Trophy Points:
    93
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello,


    I created a test filter using the instructions provided in the link which blocks email from my email user to gmail as an example:

    Code:
    # cat /usr/local/cpanel/etc/exim/sysfilter/options/test
    if("$h_to:, $h_cc:, $h_bcc:" contains "gmail.com")
    and ("$header_from:" contains "myuser@mydomain.com")
    then fail
    endif
    Thank you,
     
  5. bcadej

    bcadej Member

    Joined:
    Aug 20, 2015
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Slovenija
    cPanel Access Level:
    Root Administrator
    If I need to add @hotmail.com, @web.de, do I just copy that if statement and replace domain?
     
  6. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    372
    Likes Received:
    21
    Trophy Points:
    93
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello,


    I would suggest creating one for each domain/user and naming them accordingly. That way if you run into an issue with one of them or you need to remove one it will be easier to disable/modify.
     
  7. bcadej

    bcadej Member

    Joined:
    Aug 20, 2015
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Slovenija
    cPanel Access Level:
    Root Administrator
    It doesn’t work.


    WHM >> Home >> Service Configuration >> Exim Configuration Manager. In the Basic Editor section, the Filters tab >> Custom Filter: mailinator

    There is a yellow exclamation mark >> The setting, filter_mailinator, was not set in the configuration file, so the default has been used.



    Where/how to I set this in the configuration file?
     
  8. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    372
    Likes Received:
    21
    Trophy Points:
    93
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello,

    Can you show me the permissions and rules within your filter file?

    Code:
    stat /usr/local/cpanel/etc/exim/sysfilter/options/filter_mailinator
    Code:
    cat /usr/local/cpanel/etc/exim/sysfilter/options/filter_mailinator
    Thank you,
     
  9. bcadej

    bcadej Member

    Joined:
    Aug 20, 2015
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Slovenija
    cPanel Access Level:
    Root Administrator
    - Removed -

    Code:
    [root@vps ~]# stat /usr/local/cpanel/etc/exim/sysfilter/options/filter_mailinator
    stat: cannot stat ‘/usr/local/cpanel/etc/exim/sysfilter/options/filter_mailinator’: No such file or directory
    

    Code:
    [root@vps ~]# cat /usr/local/cpanel/etc/exim/sysfilter/options/filter_mailinator
    cat: /usr/local/cpanel/etc/exim/sysfilter/options/filter_mailinator: No such file or directory
    
     

    Attached Files:

    #9 bcadej, Apr 11, 2018
    Last edited by a moderator: Apr 11, 2018
  10. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    372
    Likes Received:
    21
    Trophy Points:
    93
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello,


    Did you create the file as indicated by the documentation? Based on this it doesn't appear to exist. The steps are:

     
  11. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    372
    Likes Received:
    21
    Trophy Points:
    93
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello,

    If the filter is just mailinator then the commands to view it should be:

    Code:
    stat /usr/local/cpanel/etc/exim/sysfilter/options/mailinator
    Code:
    cat /usr/local/cpanel/etc/exim/sysfilter/options/mailinator
     
  12. bcadej

    bcadej Member

    Joined:
    Aug 20, 2015
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Slovenija
    cPanel Access Level:
    Root Administrator
    The striked out is an email.
     

    Attached Files:

    • cat.PNG
      cat.PNG
      File size:
      26.3 KB
      Views:
      5
  13. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    372
    Likes Received:
    21
    Trophy Points:
    93
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @bcadej

    The bottom of that appears to be cutoff is the final line in that file "endif"?

    Can you also run /scripts/buildeximconf and let me know if the issue persists?


    Thank you,
     
  14. bcadej

    bcadej Member

    Joined:
    Aug 20, 2015
    Messages:
    14
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Slovenija
    cPanel Access Level:
    Root Administrator
    I've found the problem.

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

    How to create a custom filter rule file


    Number 4 says ‘Disable any undesired filter rules.’

    In WHM in Filter tab: the new line stated ‘Custom Filter: mailinator’ in the right column ‘on’ was selected and under on default is written.


    So the number 4 says ‘Disable any undesired filter rules.’ – I didn’t need to disable any rules so I didn’t do anything.

    Also not number 5, which is ‘Click Save.’

    Now I've clicked Save.

    Now it works.


    Thank you.
     
  15. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    372
    Likes Received:
    21
    Trophy Points:
    93
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @bcadej


    Thank you, for updating the results, I'm glad you were able to get it working for you.


    Thank you,
     
Loading...

Share This Page