http://www.perlmonks.org?node_id=368878

This snippet can back up your mbox messages onto Gmail.
#!/usr/bin/perl use strict; use Email::Folder; use Mail::Mailer; my $email = '@gmail.com'; my $folder = Email::Folder->new($ARGV[0] || die); foreach ($folder->messages){ print $_->header("Subject").$/; my $mailer = new Mail::Mailer; $mailer->open({ To => $email, From => $_->header("From"), Subject => $_->header("Subject"), }); print $mailer $_->body; $mailer->close; }