Chapter 14 — Exporting Your Mail 201
Listing 14-3: Appending to IMAP
use Utils;
use Net::IMAP;
$gmail = login();
$imap = new Net::IMAP( “IMAP SERVER ADDRESS”, Debug => 1 );
$imap->login( “USERNAME”, “PASSWORD” );
$messages =
$gmail->get_messages( label =>
$Mail::Webmail::Gmail::FOLDERS{“INBOX”} )
; # simply get all messages from INBOX
foreach ( @{$messages} ) { # and iterate through them
$message = $gmail->get_mime_email( msg => $_ ); #
retrive MIME message
$imap->append( “INBOX”, $message ); # and append it to
the IMAP INBOX
}
$imap->logout();
By now, as you come to the end of this book, you should be confident in dealing
with mail within the archive and under different labels. I leave it to you as an
exercise, therefore, to move labeled mail into the IMAP folders.
And Now...
For the final chapter of the book, you’re going to look at the different applications
that have already been written using the techniques you’ve learned in this section.