Hello,

First, I must say MIMEDefang is awesome and thank you for this excellent 
software.

Am a causal email hacker trying to keep my private MTA alive in the ever 
thickening email jungle.  Lately have been increasing the degree of 
customization in MIMEDefang, with a trigger being the need to hard-bounce via 
filter_sender() a recent clueless M$ outlook.com null-sender spam barrage, and 
the desire to hard bounce obfuscated-sender ESP spam from unknown ESP clients.

Just reached the point where it is necessary to scan message text bodies with 
perl regexs and modify dispositions based on that.

The MIME::Tools aspect of hacking MIMEDefang could really benefit from a short 
but technically informative paragraph in the MAN pages and other documentation.

I just spent a day butting my head against the fact that filter_begin() is 
_always_ passed a multipart MIME message container that _never_ has a useable 
$entity->bodyhandle().  This is not mentioned *anywhere*.

Would have saved me that day if the above tidbit were mentioned and that one 
can easily write something similar to

my $bdyscn_flag = 0;
my $part0 = $entity->parts(0);
my $bh = defined $part0 ? $part0->bodyhandle : undef;
if (defined $bh && (my $bio = $bh->open("r"))) {
    while (defined($_ = $bio->getline)) {
        chomp;
        if (m/MATCH SOME TEXT/) {
            $bdyscn_flag = 1; last
        }
    }
    $bio->close;
}
if ($bdyscn_flag) {
   # do something
}

to solve this sort of problem without resorting to calling

   $entity->make_singlepart()

which will (presumably) fail if MIME attachments are present.

-----

Also a warning to newbies to *not* try using INPUTMSG for this sort of activity 
would be very helpful.  Was frustrating learning the hard way that an INPUTMSG 
filter that works nicely with a simple netcat/nc/ncat plain-text test message 
will fail when presented with encoded body text from a remote MTA.  In vivid 
contrast to the normalized HEADERS file, INPUTMSG is not useful.

The most helpful bit of code to read for quickly grasping the streaming 
recursive-container nature of MIME is MIME::Tools::dump_entity().  Worth a 
mention in introductory material.

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to