Mail archiving scripts?

2001-04-04 Thread Neil Ford

Following on from recent topics, can anyone point me at any scripts to help
with breaking up mailbox files?

I did have one, but that used the From field which unfortunately get's munged
if you use Formail/Procmail to reprosses a mailbox. Ideally I'm looking for
something that uses the Date: field and would take as input a month and year,
e.g.: March 2001, a mailbox, e.g.: london-pm and create a new file of the 
mails matching those criteria, suitably named, say london-pm.2001.03.

Pointers to something suitable are fine but please bear in mind my perl is
rudimentary... okay it's non-existent :-)

Neil.



Re: Mail archiving scripts?

2001-04-04 Thread Jonathan Stowe

On Wed, 4 Apr 2001, Neil Ford wrote:

 Following on from recent topics, can anyone point me at any scripts to help
 with breaking up mailbox files?

Mr Barr's mailtools have all the gubbins required - available from your
local CPAN :)

#!/usr/bin/perl -w

use strict;

use Mail::Util qw(read_mbox);
use Mail::Internet;
use Mail::Header;
my $mess_list = read_mbox('/var/spool/mail/gellyfish') || die "Aieee\n";
foreach my $message (@{$mess_list} )
{
   my $mail = Mail::Internet-new($message);
   my $head = $mail-head; # A Mail::Header;
   print "Mail from : ",$head-get('From'),
 " Subject : ", $head-get('Subject'),"\n";
   foreach my $body_line (@{$mail-body})
{
  print $body_line;
}
}

For instance ...

/J\





Re: Mail archiving scripts?

2001-04-04 Thread Simon Cozens

On Wed, Apr 04, 2001 at 10:50:34PM +0100, Neil Ford wrote:
 Following on from recent topics, can anyone point me at any scripts to help
 with breaking up mailbox files?

This is what I do:

Use Mail::Audit in a loop over the mailbox, doing something like this:

 my ($y, $m) = (localtime)[5,4];
 my $date = sprintf("%04d%02d", $y+1900, $m+1);
 
 my %lists = (
regexp = "listname",
...
 );

for my $what (keys %lists) {
  my $where = $lists{$what};
  if ($from =~ /$what/i or $to =~ /$what/i or $cc =~/$what/i) {
$item-accept($folder.$where."-$date");
return;
  }
}
 
This means your mail gets filed to boxes like "london.pm-200104".
If you're using Mail::Audit for your incoming mail, this solution will
mean that new mail automatically gets filed to month-stamped mailboxes
as it comes in. When mutt scans your mailbox directory for new mail, it'll
pick up the new mailbox at the beginning of the month. Neat, eh? :)

-- 
} /* the next line is indented funny to preserve old indentation */
- plan9 has a bad day