Arrow-SEO logo

More about McGmail  

To free up space in my IMAP account I wrote McGmail, a relatively simple bash / shell (yes, I know, it's redundant) script to make a daily, uncompressed back-up of older eMails. There are a number of eMail Clients that do this, but I built McGmail to do this with ALL clients. Right now I've tested it with Thunderbird, Evolution and Claws-Mail/Sylpheed on Ubuntu Linux, and I would really appreciate any feedback the community may have on McGmail on the Windows side (I don't currently have a Windows partition). In the background, along with a few other "projects" I'm working on a Mac OSX port.

In the command-line/terminal type:

$ mcgmail email-client

Substituting your chosen eMail Client and address, of course. You can copy the code for McGmail here.

McGmail in action on the CLI

When running, McGmail copies all IMAP eMails OLDER than 120 days on the specified IMAP eMail account and renames them according to receive date and sender. Along with any folders, eMails are copied to an 'archives' folder that sits right in the main Client's directory (folder) tree.


I'm figuring that anyone trying this has some knowledge of scripts, so I provide the steps below mainly with that audience in mind. If you need more detailed instructions that are not covered in the script itself, please shoot an eMail to

To fully take advantage of the MH-format back-up, thus producing a single file for each eMail, I recommend that you...

  1. File any eMails from 'Inbox' or 'Sent' folders into the desired final folder.
  2. Synch all your local folders to the remote IMAP folders.
  3. Run McGmail for the first time
  4. THEN delete IMAP eMails older than 125 days.
  5. If this works, and you feel up to the challenge, next you...

  6. Configure McGmail to run daily as a 'cron job.'
  7. Configure your eMail Client to automatically delete IMAP eMails older than 125 days.

This should keep your IMAP folders relatively free from clutter, open up some of that valuable "cloud" storeage, AND still provide you with a full back-up for your records.

By design, McGmail currently skips over any eMails directly in the 'INBOX' and 'Sent' directories. Once those eMails are properly filed, they will be in the next back-up. There are instructions within the script to disable or alter these settings.

McGmail is offered free of charge, with no warranties of any kind. Use McGmail at your own discretion.

McGmail also relies on the following scripts or packages for full functionality:

Valentin Koch (eMail Valentin) wrote 'mbox2mh' to convert mbox format to MH format, and the packages 'readpst' and 'libpst' work to convert Outlook's .pst files in MH format for back-up. They can be downloaded from most distro repositories.