I need to reinject spam for testing on a server… but using the simple mail command is not sufficient to reinject messages with their headers…

We’ll use the sendmail command (even for Postfix):

  for i in message.*; do cat "$i" | sendmail -f from@domain.tld to@domain.tld ;done
  

The Postfix sendmail command implements the Postfix to Sendmail compatibility interface:

  -f sender
Set the envelope sender address. This is the address where delivery problems are sent to, unless the message contains an Errors-To: message header.
  

To get “fresh” spam samples, you can use SpamArchive.org

  wget ftp://spamarchive.org/pub/archives/submit/679.r2.gz
  

And a small script to split everything:

  cat convert
#!/usr/bin/perl -pl
if ( /^From / ) { close(OUT); open(OUT, ">>message.".$i++) || die "Can't open new file! $i\n"; select(OUT); print STDERR "Opened $i"; }
# ./convert 679.r2
  

Last updated 03 Oct 2006, 13:36 CEST. history