[Mimedefang] attach original SPAM as message/rfc822

Yanick Quirion neokimia at hotmail.com
Sun Nov 16 12:43:34 EST 2003

Hi all,

I'm looking to get a script that will attach the original SPAM as an 
attachement (message/rfc822). I found this script on the web, it works when 
I test it using text e-mail, but it doesn't seems to work with SPAM that are 
in html form (in that case, I don't have any attachement to the e-mail, only 
the SA report).

Here is the code I found in this list:

            if ($hits >= $req) {

               # If the message is "probably spam" according to SA,
               # replace the message body with the spam report and
               # attach the entire original message as message/rfc822

               # Build container object for original message
               my $container   = MIME::Entity->build(
                  Type => 'message/rfc822',
                  Description => 'Original Message',
                  Data => [ "" ]

               # Build new MIME::Entity containing original message
               # by parsing the full message text with MIME::Parser
               my $parser      = new MIME::Parser;
               open(IN, '< ./INPUTMSG');
               my $originalMsg = $parser->parse(\*IN);

               # Add original message to container entity...

               # Build the SA report
               my $reportPart  = MIME::Entity->build(
                  Type => 'text/plain',
                  Data => [ $report ]

              # Replace all existing parts of the current message with
              # the SA report

              # Rewrite the MIME boundary so that it's different from
              # the one in the attached original message
                   => "----------=_".scalar(time)."-$$-343"

              # Add the container (original message as attachement)
              # and rebuild the message

Anybody have a solution or another script that will work for all e-mail 



Yanick Quirion

The new MSN 8: advanced junk mail protection and 2 months FREE*  

More information about the MIMEDefang mailing list