Re: [Hampshire] Bash script for forwarding spam from an mbox

Top Page
Author: Hugo Mills
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] Bash script for forwarding spam from an mbox

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x56be9100.hantslug.org.uk.3721': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Mon Jul 16 22:50:58 2007 BST
gpg: using DSA key B2C27BC21C335860
gpg: Can't check signature: No public key
On Mon, Jul 16, 2007 at 09:59:02PM +0100, Graeme Hilton wrote:
> Currently I manually check the Junk folder once a day and move all
> spammy mails to JunkSpam, and non-spammy mails to the JunkNotSpam.
> Overnight I have a cron script that feeds the mails to SpamAssassin[1].
> I'd also like this script to detect which mails have been missed by the
> ISP (don't have [-SPAM-] in the subject or have DSPAM: INNOCENT as a
> header), and then forward them individually, inline to the ISPs training
> address.
>
> Does anyone have any pointers to a shell scripting tutorial that might
> be able to help me split out the emails from an mbox? Googling for
> various combinations of "shell script mail forward mbox" doesn't give me
> much to work with.


Probably the thing to do is something like this:

mkdir split && cd split
csplit -b %04d ${MBOXFILE} '/^From /' '{*}'

That will generate a file in the directory "split" (put it in /tmp
or wherever else you want) for each mail in the mailbox.

Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 1C335860 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
              --- w.w.w.  : England's batting scorecard ---