OT: a perl script to remail mbox email

Ken A ka at PACIFIC.NET
Fri Jun 11 16:03:18 IST 2004


I use this to split large mailboxes into separate files named
message.0001...

------- snip -----

#!/usr/bin/perl
$progname = 'mailsplit';
$tag = '^From ';
$n = 1;
$is_open = 0;
while( <> )
{
         if( $_ =~ /$tag/ )
         {
                 close( FILE) if $is_open;
                 $file = sprintf( "message.%04d", $n);
                 open( FILE, ">$file") || die "$progname: $! ($file)\n";
                 $is_open = 1;
                 $n++;
         }
         print( FILE $_);
}
close( FILE) if FILE;

------ snip ------

The problem that complicates this is that the header "To :" field may
not be the same as the envelope recipient, and may contain several email
addresses (meaning you'll have duplicate emails in the trash mbox too).

You'd actually have to grep the log by msgid for the original recipient
to match these up I think. How tough this is depends on what your idea
of fun is. :-)

Ken A
Pacific.Net


Christopher Schanzle wrote:

> Jeff A. Earickson wrote:
>
>> Gang,
>>
>>  I screwed up my procmail rules yesterday and had procmail deliver
>> all of my inbound email into a "trash" mbox file for a while.  Ouch.
>> I then had 1200+ messages that I had to get delivered to their proper
>> recipients somehow.  I googled for some kind of script that would
>> rip apart an mbox file and resend messages, but found zilch (I did
>> find a lot of queries for this kind of script though).
>>
>>
>
> I have used formail, part of the procmail package, with good success in
> the past.
>
> -------------------------- MailScanner list ----------------------
> To leave, send    leave mailscanner    to jiscmail at jiscmail.ac.uk
> Before posting, please see the Most Asked Questions at
> http://www.mailscanner.biz/maq/     and the archives at
> http://www.jiscmail.ac.uk/lists/mailscanner.html
>
>

-------------------------- MailScanner list ----------------------
To leave, send    leave mailscanner    to jiscmail at jiscmail.ac.uk
Before posting, please see the Most Asked Questions at
http://www.mailscanner.biz/maq/     and the archives at
http://www.jiscmail.ac.uk/lists/mailscanner.html



More information about the MailScanner mailing list