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

Craig Green cgreen at sentex.net
Mon Jul 18 12:54:42 EDT 2005



McCarthy, Douglas J wrote:

>The good news is that it catches Out of Office AutoReplies exactly
>right!
>The bad new is that it's not catching the User-Agent or X-Mailer things
>at all.  I know how to set them, and when they get delivered the headers
>are indeed there, but if I uncomment that VacDebug logging line, I see
>that $UserAgent never gets set, and $XMailer gets set to "MIME-tools
>5.411 (Entity 5.404)", even though the User-Agent: line is set to
>"Vacation" and/or the X-Mailer" line is set to "vacation".
>  
>

I was wondering about this--from what you said, you're running version 
2.44 of MD.  This, unfortunately, is from before I started messing 
around with MIME entity in the filter (the server with the code in 
question is 2.49).  Taking a quick look at the 2.44 code, it looks like 
a MIME entity is passed into filter_end, so $entity should actually *be* 
a MIME entity, which is a good start.  I'd still suggest upgrading MD to 
latest, however.

If MD is that old, it also wouldn't surprise me if you're running an old 
version of MIME::Tools, too.  Perhaps your MIME::Tools doesn't support 
something, or bugs were fixed or something (like I said, I haven't been 
playing with this for long, so I don't know the module's history).  As 
such, I'd certainly update MIME::Tools.

>I'll admit that I have no idea what I'm doing when it comes to packages
>like MIME::Entity.  
>

Neither did I, but that's what docs are for.  Take a look at:

http://search.cpan.org/~dskoll/MIME-tools/lib/MIME/Entity.pm
http://search.cpan.org/~dskoll/MIME-tools/lib/MIME/Head.pm


Getting the head out of a MIME entity is straightforward (see "Access 
Examples" in Entity) and getting a specific header out of the head is 
also straightforward (see "Getting field contents" in Head).  I'm 
certainly no guru, so by definition this is fairly easy stuff.  :-)

You might want to try $head->print to see if the head is being extracted 
correctly. You might also want to code a simple script to create or read 
in a MIME message, and then try out the head functions to see if they 
work correctly outside MD.  You can cut and paste most of the code you'd 
need from the above pages.

Note that since you're in filter_end, the HEADERS file *is* available, 
so you can just parse that if you'd prefer.  There was nothing wrong 
with your initial logic; it's just that parsing the file on disk is 
slower *and* it takes more code than using the MIME entity.  However, if 
it works, it works.  ;-)

Craig.
------




More information about the MIMEDefang mailing list