Other How do I download and archive mails from an old account?

Hello,

I have several thousands of emails on my Gmail account which is still active, but I haven't been using it for years.

I would like to:
* download all the emails to maildir (or similar) on my hard disk, and
* be able to index, browse and read them, but preferably without importing them to a mail client (because I do not want to connect to the Gmail account).

Could you please advice which programs or tools I should use? Every guide I can find is presuming that one would like to continue using the account normally. But I just want an offline easy-to-browse archive of emails on my PC. The account as such is no longer of relevance to me.

Thanks.
 
mail/imapsync can be used to migrate / copy any mail account that you can reach via IMAP to a local IMAP acount.
Of course, this means you'll have to set up a local IMAP server to store you mail first.
 
There is a facility in gmail to download all of your data or a certain set of data in mbox format. Go to https://takeout.google.com/ and follow the instructions. You can get labelled emails from that. I used this to pull all my IMDB movie reviews out of the gmail account after I closed my IMDB account, since IMDB always sends you a copy. Then I used a script to process that. Here is the relevant bit of it:

Perl:
use Mail::Box::Manager;

my $file = "$Bin/IMDB.mbox";
my $mgr = Mail::Box::Manager->new(
    access      => 'r',
);


my $folder = $mgr->open (folder => $file)
    or die "$file: Unable to open: $!\n";

for my $msg ($folder->messages) {
    my $date    = $msg->timestamp ();
    my $body    = $msg->body ();
    my ($title,$text, $summary) = get_content ($body);
    # Do something with data
}
 
There is mbox export in Gmail (as said above). Mbox format can be read by most local applications for mail such as mutt or thunderbird or apple mail or whatever. They won't connect to google when you mess with mboxes. Mutt is very convenient for quick searches.
 
Back
Top