Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-09-19 07:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (132 votes), past polls