Need - Perl script to split mail folder 
Author Message
 Need - Perl script to split mail folder

I need a Perl script that will take an Elm mail folder and split the contents
into individual message files that I can then feed into another script I have
that I use to moderate a Usenet newsgroup with. If anyone has one, I sure
wish you would mail me a copy. Alternatively if you are a Usenet newsgroup
moderator and have a Perl script that does it all (splits messages, posts
approved articles, sends acknowledgements, etc.) I'd love to have a copy of
it. Any help would be greatly appreciated.

-----------------------------------------------------------------------------

Moderator - soc.history.war.world-war-ii
-----------------------------------------------------------------------------



Sun, 23 Nov 1997 03:00:00 GMT  
 Need - Perl script to split mail folder
: I need a Perl script that will take an Elm mail folder and split the contents

Here is a script that splits an ordinary mail folder:
-----cuthere-----
#!/ufs/sgi428/uf1/perl5/bin/perl

require 'getopts.pl';
&Getopts ( 'h' ) || ( &usage, exit ) ;

&usage, exit if $opt_h;

$|++;

foreach $f ( <m.???> ) {
   die "already exists: '$f'\n";

Quote:
}

$wasblank = 1;
while ( <> ) {

   if ( /^From/ && $wasblank ) {
      $file = sprintf ( "m.%03d", ++$count );
      open ( FILE, ">$file" ) || die "cannot open >$file\n";
      print '.'; $dots = 1;
   }

   print FILE $_;
   $wasblank = /^\s*$/;

Quote:
}

print "\n" if $dots;

sub usage {
   print <DATA>;

Quote:
}

__END__

Name:
   mailsplit

Purpose:
   Split a mailbox file into individual mail messages

Usage:
   mailsplit -h
   mailsplit mailfile

where
   -h       -- displays this help info, then quits (does not execute)
   mailfile -- is the mailbox file containing the mail messages

Example
   mailsplit ~/mbox
      Splits the mailbox file named 'mbox' in your home directory into
      individual mail messages. The first mail message from ~/mbox is
      stored into 'm.001', the second into 'm.002', etc. The original
      file, ~/mbox in this case, is not changed in any way.

Notes

(*) The diff command below should show no differences:
       cd
       mailsplit mbox
       cat m.??? > a
       diff mbox a

(*) If any m.??? file already exists, mailsplit will refuse to do its
    thing. You'll be notified.
--

-----cuthere-----
--
--
jan b schipmolder



Sun, 23 Nov 1997 03:00:00 GMT  
 Need - Perl script to split mail folder
You don't want Perl for this you want procmail.

ftp://ftp.informatik.rwth-aachen.de/pub/packages/procmail/

enjoy.

Jimc



Tue, 25 Nov 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Filter mail by folders with Perl

2. Piping mail to a script that splits off attachments (Mailtools)

3. Need Help with Perl Script Implementation for e-Mail .HTM Form

4. Need Perl script to receive email from mailing list

5. Mail::Folder buglet?

6. ANNOUNCE Mail::Folder v0.07

7. Reading mail folders as newsgroups

8. Removing duplicate mail messages from a folder

9. Move Mail Between Folders

10. MIME::Parser and Mail::Folder

11. Processing mail folders one message at a time

12. MIME::Parser and Mail::Folder..

 

 
Powered by phpBB® Forum Software