How to back up emails from the email server?

Posted on In QA

offlineimap actually does “synchronization”—if an email is deleted from the server, the email will be deleted from the local Maildir (http://offlineimap.org). This is good for mail sync.

However, for backing up emails,one would like to keep the email even if it is deleted from the server. How to achieve this?

You may use `getmail` which can retrieve emails through pop3 and imap4 and save the emails to maildirs and mboxrd files.

getmail is a mail retriever designed to allow you to get your mail from one or more mail accounts on various mail servers to your local machine for reading with a minimum of fuss. getmail is designed to be secure, flexible, reliable, and easy-to-use. getmail is designed to replace other mail retrievers such as fetchmail.


You can use fetchmail + procmail to fetch email from pop3 which is usually supported by email servers and store the email in Maildir.

There are lots good tutorials on the Web which you can refer to:

Backup your Gmail account in maildir format using fetchmail: http://blog.wains.be/2008/03/19/backup-your-gmail-account-in-maildir-format-using-fetchmail/

Managing your email with fetchmail, procmail and mutt: http://easierbuntu.blogspot.com/2011/09/managing-your-email-with-fetchmail.html

Using fetchmail and procmail for maildir style storage from a pop3 account: http://www.ioncannon.net/system-administration/97/using-fetchmail-and-procmail-for-maildir-style-storage-from-a-pop3-account/

Geek to Live: Back up Gmail with fetchmail: http://lifehacker.com/235207/geek-to-live–back-up-gmail-with-fetchmail

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *