Email Rule to filter (delete or move) all domains except from .com?

USA_Webmaster

Well-Known Member
Dec 10, 2015
64
10
58
USA
cPanel Access Level
Root Administrator
Can you please help me write a rule to delete or move email to a folder for all incoming email address that ARE NOT a .com? Really, what I would love is to just route all email that isn't .com, .net, or .org to a subfolder so I can review them manually. But mostly, all junk / spam mail seems to be from non .com domains. I even use spambar or spamassasin.
 

asmithjr

Well-Known Member
Jun 13, 2003
516
8
168
Can you just do this in you cPanel account by creating a filter?
I tested making one and it created this in my filter file.
Code:
#move not com
if
$header_from: does not contain ".com"
then
  deliver "##@######.com"
endif
 
  • Like
Reactions: USA_Webmaster

USA_Webmaster

Well-Known Member
Dec 10, 2015
64
10
58
USA
cPanel Access Level
Root Administrator
Can you just do this in you cPanel account by creating a filter?
I tested making one and it created this in my filter file.
Code:
#move not com
if
$header_from: does not contain ".com"
then
  deliver "##@######.com"
endif
Thanks for the reply but when I use the cPanel > Email Filters > Create Filter area I do not see where I can paste raw code. I've not made a "Any Header" rule before but I reckon this should do!! Thanks buddy for teaching me about headers.

Quick question, if using the website, does it matter if the rule uses "com" or com ... the quotes?

1627568625501.png

p.s. - i think if i would have logged into FTP, etc/domain.com/user/filter i would have been able to manually add rule.
 

asmithjr

Well-Known Member
Jun 13, 2003
516
8
168
I should have left it with just use the cPanel create method. Forget I posted the code.
No need to put the .com in quotes.
Now in you screen example change the Deliver to Folder to Forward to email if you want it to go to an email account you can monitor.

You will need one for each extension you are trying to do this with.