[Mimedefang] Making a backup of filtered spam

Sidney Markowitz sidney at sidney.com
Tue Aug 6 07:08:00 EDT 2002


I'm using SpamAssassin with MimeDefang, with action_defang on anything that is
flagged as spam, so that it doesn't show up with nasty stuff when I look at it. This
has caused problems with the occasional false positive, that is then hard to read if
it is anything except plain text.

Here is some code I added to mimedefang-filter in filter_end after calling
SpamAssassin and determining that a mail message is spam. It is supposed to put the
original, untouched message in a separate attachment that I can open if after looking
at the defanged version I decide that it is not spam after all. It also gives easy
access to the original message in case I want to use it to report to razor or to
someone else who needs to see it in an unmangled form.

I am not fluent in perl and would appreciate any comments, criticisms, or suggestions
from someone more experienced with it.

Note that earlier in filter_end there is a test that causes this section of code not
to be called if a mail message is larger than 256Kbytes, so I know that it is not too
large to read into an array all at once:

 # allow for easy recovery of original message by making a pristine attachment
 if (open (IN, "<./INPUTMSG")) {
    my @msg = <IN>;
    close(IN);
    action_add_part($entity, "message/rfc822", "-suggest",
                    join('', @msg),
                    "backup_of_spam.eml", "attachment");
 }


Thanks for any feedback about this.

  -- sidney





More information about the MIMEDefang mailing list