On Sun, 2017-05-07 at 00:37 +0200, Benny Pedersen wrote:
> why not back that spam up to gmail ? :=)
> 
Even easier: save them to a directory as text files and make sure
that's included in your daily/weekly backups.

The only other thing you need is a way remove SA headers from your spam
collection. A bash script using awk to do the heavy lifting works for
me:

=========================== cleaner ===========================
#!/bin/bash

if [ "$1" == '-?' ]
then
   echo "Syntax:   cleaner [file...]"
   echo "Function: Remove SA headers from example message(s)"
   echo "          If a list of files is present they are processed."
   echo "          If no list is supplied, all files in data/* are"
   echo "          processed."
   echo "Options:  none"
   exit
fi

function clean()
{
        echo "Cleaning $1" 
        gawk '
                BEGIN           { act = "copy";
                                  body = "no";
                                }
                /^[A-Za-z]/     { act = "copy"    }
                /^X-Spam/       { act = "skip"    }
                /^$/            { body = "yes"; }
                                {  
                                  if (act == "copy" || body == "yes")
                                        { print }
                                }
        ' <$1 >temp.txt
        mv temp.txt $1
}

if [ $# -gt 0 ]
then
        for f in $*
        do
                clean $f
        done
else
        for f in data/*.txt
        do
                clean $f
        done
fi
=========================== cleaner ===========================


Martin

Reply via email to