[Mimedefang] regex filter unwanted words
John Rudd
john at rudd.cc
Mon Jan 22 18:17:48 EST 2007
dick hoogendijk wrote:
> Some time ago I asked about filtering unwanted words. The advice was /
> is not to do it, but I still want to try.
>
> The filter rule was something like:
>
> if($Subject =~ m// ) {
> return action_bounce("bad subject");
> }
>
> Question: do I put the unwanted words into this rule like this:
>
> if($Subject =~ m/sex|microsoft|Watch/ ) {
> return action_bounce("bad subject");
> }
>
> I'm not sure how to put in the regex. How many words can I put between
> those two slashes of m// ?
>
As many as you can fit. But I would be very careful about it. Plus, I
would make sure to use "\b" around the words, so that you're not getting
sub-string matches. For example:
\bsex\b will match "sex" but not match "Wesex".
So, maybe something like this:
if($Subject =~ m/\b(sex|microsoft|Watch)\b/ ) {
return action_bounce("bad subject");
}
However, as others have pointed out, it's not generally a good idea.
Spammers change their subjects often enough that you'll have trouble
keeping up. Plus, you'll be very prone to false-positives.
More information about the MIMEDefang
mailing list