[Mimedefang] Re: Mimedefang filter "From:" header
Yizhar Hurwitz
yizhar at mail.com
Mon May 7 18:00:18 EDT 2007
HI.
> I want to filter information in the "From:" header.
> From: "John Doe" <john.doe at johndoe.com>
> I am able to filter out the address but I would rather filter the "John
> Doe" portion.
> $bad_from = '.*John Doe.*|.*John Doe2.*';
> sub filter_sender {
> my ($sender, $ip, $hostname, $helo) = @_;
> if ($sender =~ /^$bad_from$/i) {
> return ('REJECT', 'No spam please.');
> }
I have 2 additional notes, In addition to the comment from David about
the headers,
1. If applicable, it is better to let sendmail filter the sender,
using the "access" file.
So first you should better see if you can do something in "access", and
if no good, revert to second choice - mimedefang.
Using sendmail rules will allow you to reject earlier and cheaper.
2. Regarding your regexp
> $bad_from = '.*John Doe.*|.*John Doe2.*';
I think that you can improve the above line, but I don't know exactly
how (it depends also on your exact needs).
Maybe this:
$bad_from = 'John Doe|John Doe2'
If you haven't done so already, try to (re)read:
man perlretut
and other perl regexp manuals .
Again - the exact syntax depends on what exactly are you looking for
(partial match or the exact name),
in your example I think that you can easily do it better without the
.(dot) and *(star) characters inside the regexp.
My 2 tips,
Yizhar Hurwitz
http://yizhar.mvps.org
More information about the MIMEDefang
mailing list