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

bcadej

Member
Aug 20, 2015
21
1
53
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:

[email protected] – can send email to everybody

[email protected] – 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
 
  • Like
Reactions: Tarak Nath

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
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 "[email protected]")
then fail
endif
Thank you,
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
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.
 

bcadej

Member
Aug 20, 2015
21
1
53
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?
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
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,
 

bcadej

Member
Aug 20, 2015
21
1
53
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
 

Attachments

Last edited by a moderator:

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
Hello,


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

  1. Create a file in the /usr/local/cpanel/etc/exim/sysfilter/options/ directory.
  2. Within that file, enter your custom filter rules. For example, to block mail from [email protected], add the following rule:

    Code:
    if ("$h_from:" contains "[email protected]")
    then fail
    endif
  3. Navigate to WHM's Exim Configuration Manager interface (WHM >> Home >> Service Configuration >> Exim Configuration Manager). In the Basic Editor section, select the Filters tab.
  4. Disable any undesired filter rules.
  5. Click Save.
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
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
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
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,
 

bcadej

Member
Aug 20, 2015
21
1
53
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.