Skip to content

Instantly share code, notes, and snippets.

@dlangille
Created January 4, 2015 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/9dacd1ab7933b67702bf to your computer and use it in GitHub Desktop.
Save dlangille/9dacd1ab7933b67702bf to your computer and use it in GitHub Desktop.
Mail recovery solution
In a recent blog post, I showed how I copy mail off to another location which it is archived, mbox fashion.
see http://dan.langille.org/2013/10/19/using-mbox-for-mail-backup/
What I didn't do at the time was come up with a recovery method. Today, I found one.
First, determine what messages need to be added to your restored Maildir. Copy those files to the IMAP server.
Then run this command:
cat mbox.backup | formail -ds sh -c 'cat |/usr/local/bin/maildrop -d ${USER}'
My IMAP server uses maildrop for the final delivery:
$ cat ~/.forward
"|/usr/local/bin/maildrop -d ${USER}"
The above command takes the mbox backup and reinjects it as if it was just being delivered gain. NOTE: the headers you see within the email will match those of the backup site, not the primary site.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment