[Mimedefang] RE: Filtering on sender, recipient, and subject at the same time

McCarthy, Douglas J dmccart at intel.com
Fri Jul 8 14:44:20 EDT 2005


Thanks for all the replies!  I will address them in order here.

> From: <Matthew.van.Eerde at hbinc.com>
> 
> There's an Exchange checkbox for this -- "no out-of-office replies to
the
> internet" or something.  What version of Exchange are you using?

I know about that setting - we currently have it set, actually - but the
problem is that we have a heterogeneous mail environment.  Some people
use Exchange, some people don't.  When a non-Exchange user sends mail to
an Exchange user with OOOA turned on, the Exchange policy blocks the
autoreply from going to the non-Exchange user.


> From: "Damrose, Mark" <mdamrose at elgin.edu>
> 
> filter_recipient fires as each recipient is specified and before the
> message
> body.  The headers (including subject) are part of the message body.
> MIMEDefang can't give you information that doesn't exist yet.  This
logic
> needs to move somewhere else, such as filter_begin or filter_end.

Ah ha!  I'll try moving it to filter_begin, then.

The cool part about having it be in filter_recipient would be that I
could use the ACCEPT_AND_NO_MORE_FILTERING return code before any of the
anti-spam and anti-virus stuff got called.  Another part of our setup
requires that spam sent from these systems arrive unfiltered at another
company-owned system, and we had been using ACCEPT_AND_NO_MORE_FILTERING
to allow that.

I will have to figure out a different way to implement that.


> From: Craig Green <cgreen at sentex.net>
> 
> If I'm not horribly, horribly mistaken, filter_recipient is called
after
> each RCPT TO: command during the SMTP conversation.  RCPT is before
the
> DATA phase, when the headers--including the subject--would get
> transmitted.  Accessing HEADERS is giving "No such file" errors and
> $Subject isn't available because at that point neither exists...
> 
> I'd do what you're trying in filter_end.  Autoreplies would only go to
> one person so you don't have to worry about multiple recipients and
can
> just use action_discard().
> 
> I also wouldn't use egrep to search the HEADERS file when you can just
> access the headers within the MIME entity passed in, but I don't know
if
> 2.44 supports that.
> 
> sub filter_end ($) {
>     my($entity) = @_;
> 
>   if ($Sender =~ /\@mycompany.com>?$/i &&
>     $Recipients[0]  !~ /\@mycompany.com>?$/i) {
> 
>     my $header = $entity->head; # Extract a MIME::Head object from the
> MIME::Entity object '$entity'.
> 
>     if ($header->get('User-Agent') =~ /Vacation/ ||
>         $header->get('X-Mailer') =~ /vacation/ ||
>         $Subject =~ /Out of Office Autoreply/ ) {
>             action_discard();
>     }
>   }
> 
> # Spamassassin checks, etc.
> 
> }
> 
> Note: untested.  YMMV.

Thank you very much!  I didn't know how to use the MIME entity the right
way; I will certainly try this.

						-Doug McCarthy





More information about the MIMEDefang mailing list