Jump to content
xisto Community
Sign in to follow this  
vujsa

Filtering Out Unwanted Junk Mail Using Regular Expression. Use this Regular Expression with the cPanel email filter to limit your

Recommended Posts

I'm so irritated with the amount of spam I get on the email accounts I have hosted at Xisto. It isn't the servers fault that I get so much junk mail! It wouldn't be so bad but my junk mail filter on my home system doesn't scan IMAP accounts which I use since my email client won't separate POP3 accounts properly.

So I finally got to the point I had to do something! I'm getting about 25 junk mail messages a day spread over 5 different email accounts. If I go a few days without checking my email, I have a lot of work to do to clean out the trash!

The good news it that cPanel has an email filter available that can help. Here is what I did...

First, I set up an email account simply named "junkmail"!
Then I go to the email filter page and click on the "Add Filter" link.

We first do a filter for the body of the message by selecting "Body".
We then select "matches regex".
And for destination, we enter "junkmail@mydomain.com".

This will filter all of your email messages and move unwanted emails to the junkmail account where you can review them prior to deletion.
The regular expression I use is shown below:

.*(sperm|pr(a|4)d(a|4)|(l|1)(o|0)(a|4)n|gener(i|1)c|^cum|p(o|0)rn|d(i|1)or|****|d(i|1)ck|sex|ph(a|4)(l|1)(l|1)us|pen(i|1)s|ro(l|1)+ex|(l|1)uxury t(i|1)mep(i|1)ece|c(o|0)ck|cred(i|1)t c(a|4)rd|debt|v((i|1)+((a|4))+)+gr((a|4))+|c((i|1)+((a|4))+)+(l|1)+(i|1)+s|penetr(a|4)te|b(l|1)ue.?p(i|1)(l|1)(l|1)|hyrd(o|0)c(o|0)d(o|0)ne|erect(i|1)(l|1)e|erect(i|1)(o|0)n|(a|4)nt(i|1).?ed|s(c)?h(l|1)(o|0)ng|ph(a|4)rm(a|4)cy|drugst(o|0)re).*

I would list the filtered words but the forum filter will filter them out!

After you set up your filter for your "Body", then do the same for "Any Header" and you'll be done.

Be sure that you use the information specific to your account. You can "Discard" filtered emails but then you risk the chance that a wanted email is forever lost!

I offer no warranty for this information. It may allow unwanted email to be delivered. It may also filter legitimate emails and if no junk mail location is set, it will delete such emails. This also filters outgoing email so you won't be able to send an email from your account that contains one of these filtered words.

Basically, use at your own risk.

This is capturing about 90% of my junk mail and hasn't filtered legitimate emails on accident.
There is a filter tester available to see if certain words will be filtered correctly.

I hope this helps. ;)

vujsa

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.