[Mimedefang] Change subject according to string match in body

Dave O'Neill dmo at roaringpenguin.com
Tue Jan 19 13:37:08 EST 2010

On Tue, Jan 19, 2010 at 03:53:51PM +0100, Johan Lundberg wrote:
> The code works as I expect when the pattern is found in the subject of
> the mail but when the script tries to look in the body Mimedefang
> crashes and I have to reread the filter file to be able get it working
> again.

What errors do you see in your mail log when it dies?  My immediate 
thought is that this code here is to blame:

>            my $body = $entity->bodyhandle;
>            my $IO = $body->open("r");
>            while (defined($_ = $IO->getline)) {

Not all MIME::Entity objects will have bodies!  For example, a 
multipart/mixed or multipart/alternative toplevel won't, leaving 
->bodyhandle to return undef into $body and causing $body->open() to 

There are two better ways to do what you're trying to do.

1) Do your body checking in filter(), as it only gets called on entities 
    with a body.

2) Open up $CWD/INPUTMSG and check the raw message directly.

Dave O'Neill <dmo at roaringpenguin.com>    Roaring Penguin Software Inc.
+1 (613) 231-6599                        http://www.roaringpenguin.com/
For CanIt technical support, please mail: support at roaringpenguin.com

More information about the MIMEDefang mailing list