Email filtering using procmail
#1
Original Poster




Join Date: Apr 2003
Location: IAD
Programs: Free Agent
Posts: 1,959
Email filtering using procmail
I don't know why, but I still use Pine as my email client. Anyway, Spam Assassin works pretty well for me, but there are some domains that I'd like to block in my procmailrc file. How would I go about doing so? I tried the following recipe, but it didn't work:
:0:
* ^From: *lan.com
/dev/null
My only guess is that it's some syntax error. Any help would be appreciated! And no, I don't have anything against LAN. I just can't get off their mailing list for some reason.
:0:
* ^From: *lan.com
/dev/null
My only guess is that it's some syntax error. Any help would be appreciated! And no, I don't have anything against LAN. I just can't get off their mailing list for some reason.
Last edited by Condition One; Mar 23, 2011 at 4:59 pm
#2


Join Date: Dec 2006
Location: SNA
Programs: Bonvoy LTTE/AMB, AmEx Plat, National EE, WN A-List Preferred, CLEAR+, Covid-19, NK Gold
Posts: 5,272
Hey- I 99% use Pine, too.
But I think the issue is your leading "*" in your recipe; these aren't "glob"-type expressions, they're full regular expressions, and as such that "*" means "0 or more of the preceding match character", which in your case is the space.
I think:
... will work, but for safety while testing change "/dev/null" to a folder so you don't inadvertently end up trashing all your mail.
But I think the issue is your leading "*" in your recipe; these aren't "glob"-type expressions, they're full regular expressions, and as such that "*" means "0 or more of the preceding match character", which in your case is the space.
I think:
Code:
:0: * ^From:.*lan.com$ /dev/null
#4
Original Poster




Join Date: Apr 2003
Location: IAD
Programs: Free Agent
Posts: 1,959
Need some more help. So if I want to block a specific email address, is this correct?
:0:
* ^From:[email protected]
/dev/null
The thumbs up is supposed to be a caret by the way! Don't know how to disable that.
:0:
* ^From:[email protected]
/dev/null
The thumbs up is supposed to be a caret by the way! Don't know how to disable that.
#5
 



Join Date: Nov 2000
Location: Upcountry Maui, HI
Posts: 13,708
You need something after the From: and before the spammers email address.
inside the square brackets you want a space followed by a tab. (I couldn't type a tab here.)
That will only match [email protected] and won't inadvertently match similar email addresses that end with the same string like [email protected]
the space tab inside the square brackets followed by the asterisk matches white space, so the expression matches "From:" at the beginning of the line, followed by zero or more white space characters, followed by [email protected]
You could use .* instead of the white space expression but that could produce some extra matches.
Anyway, try that, see if it works.
-David
Code:
:0: * ^From:[ ]*spammer@yahoo\.com /dev/null
That will only match [email protected] and won't inadvertently match similar email addresses that end with the same string like [email protected]
the space tab inside the square brackets followed by the asterisk matches white space, so the expression matches "From:" at the beginning of the line, followed by zero or more white space characters, followed by [email protected]
You could use .* instead of the white space expression but that could produce some extra matches.
Anyway, try that, see if it works.
-David
Last edited by LIH Prem; Oct 21, 2012 at 10:55 am
#6
Join Date: Apr 2005
Location: PHX
Posts: 3,794
If you're using SpamAssassin, you can also use the blacklist_from option in its config file.
For SpamAssasin, the * is just a regular wildcard, not a regular expression. You need to include the @ or you'll exclude all mail from any domain ending in ...lan.com, not just lan.com. For multiple domains, just use multiple blacklist_from lines.
This works by adding a very large value (100) to the spam score, so it will get filed according to how you're sorting your mail that's tagged as spam.
BTW, you can include special characters like ^ or :p without them being translated by checking the "Disable smilies in text" option in the "Additional Options" box below the submit/preview buttons.
Code:
blacklist_from *@lan.com
This works by adding a very large value (100) to the spam score, so it will get filed according to how you're sorting your mail that's tagged as spam.
BTW, you can include special characters like ^ or :p without them being translated by checking the "Disable smilies in text" option in the "Additional Options" box below the submit/preview buttons.
#7
Original Poster




Join Date: Apr 2003
Location: IAD
Programs: Free Agent
Posts: 1,959
Ah, thanks for the tip on disabling smilies! I was looking for it near the top. Anyway, thanks for all your help! Things appear to be working. Is there a good tutorial on writing rules that you guys could point me towards?
#9
 



Join Date: Nov 2000
Location: Upcountry Maui, HI
Posts: 13,708
there's lots of examples out there. You might need to read up on "regular expressions" also if you really want to learn how to do it.
-David

