Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Downloading IMAP Folders to mbox file

by TilRMan (Friar)
on Jun 19, 2006 at 06:17 UTC ( [id://556192]=note: print w/replies, xml ) Need Help??


in reply to Downloading IMAP Folders to mbox file

You probably need to supply some arguments to formail -- perhaps some of -Yeds -- to help it figure out where your messages start and stop. However, formail can't promise to get it 100% right, so you'll end up with mutilated and merged messages.

If you were as paranoid as I am, you would run each message through formail and concatenate the output into a single file; that file would be a valid mbox. This will take a long time for many messages; but if you are running this regularly it should be tolerable.

# Untested foreach my $flavor qw( SPAM HAM ) { my $file = "/home/mail/mbox/${flavor}.mbox"; $imap->select($flavor); my @msgs = $imap->search("ALL"); foreach my $msg (@msgs) { open my $pipe, "| formail >> $file" or die "$!"; $imap->message_to_file($pipe, $msg); close $pipe or die "$!"; $imap->delete_message($msg); } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://556192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-28 16:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found