Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Downloading IMAP Folders to mbox file

by TilRMan (Friar)
on Jun 19, 2006 at 06:17 UTC ( #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); } }

Comment on Re: Downloading IMAP Folders to mbox file
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2015-11-29 23:29 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (754 votes), past polls