[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);
               close(IN);

               # Add original message to container entity...
               $container->add_part($originalMsg);

               # 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
              $entity->parts([$reportPart]);

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

              # Add the container (original message as attachement)
              # and rebuild the message
              $entity->add_part($container);
              action_rebuild();
_END_

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

Thanks

Regards

Yanick Quirion

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca



More information about the MIMEDefang mailing list