IMAP Email Backup

栏目: IT技术 · 发布时间: 5年前

内容简介:Recently, I had some issues with my email provider and it gave me a bit of a scare as I realized that I had taken email for granted and did not have a backup in case things went south. Since my email address is run off of a domain that I own, I can easily

Recently, I had some issues with my email provider and it gave me a bit of a scare as I realized that I had taken email for granted and did not have a backup in case things went south. Since my email address is run off of a domain that I own, I can easily switch email providers. However, I use mutt and it does not download all the email bodies in all the folders so I did not necessarily have a local copy of all my emails.

IMAP Email Backup

Take my advice - I don't use it :).

Thus began the hunt for a simple email backup solution and I found it in the form of a really nice python script: imapgrab.py . Note that this script has the following requirements:

sudo apt install getmail

Once the requiremements are met, simply copy the script over to any folder and execute it as follows: ./imapgrab.py -l -s imap.mail.server -u username -p password . This will list all available IMAP folders on the provided server. To download a copy of all mails run the following:

./imapgrab.py -d -v -f ~/user@email.com -s imap.mail.server -S -p 993 -u user@email.com -p password -m "_ALL_,-INBOX.Trash,-INBOX.Spam,-INBOX.Junk,-Trash,-Junk,-Spam"

-d instructs the script to download the IMAP folders. -f provides the location to store the downloaded email. -m provides instructions as to what to download (here we download everything except the trash and spam folders). Check out the script itself for more usage parameters.

With this script running, I was able to regularly backup my email and as a bonus, here are the commands to encrypt and decrypt the backed up emails (linux specific):

# create archive
tar -jcvf ~/user@email.com.tar.bz2 ~/user@email.com 

# encrypt (could take a while)
gpg -c ~/user@email.com.tar.bz2

# delete original
rm ~/user@email.com.tar.bz2
rm -rf ~/user@email.com

# decrypt
gpg ~/user@email.com.tar.bz2.gpg

# extract
tar -xvf ~/user@email.com.tar.bz2

Once encrypted you can safely store your email archive anywhere on the cloud.

Finally, in order to actually read the emails, you can import the mailboxes in thunderbird or use mutt as I like to do: mutt -f ~/user@email.com/INBOX.mbox :).

Note that at the time of writing the script does not work with Python 3 and if you do manage to convert it, please do throw me a shout!

HackerNews submission / discussion


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

PHP 6与MySQL 5基础教程

PHP 6与MySQL 5基础教程

(美)厄尔曼 / 陈宗斌 等 / 人民邮电出版社 / 2008-11-1 / 65.00元

本书是一部经典的入门级著作,采用基于任务的方法来讲授PHP和MySQL,使用大量图片指导读者深入学习语言,并向读者展示了如何构造动态Web站点。书中用简洁、直观的步骤和讲解提供了学习任务和概念的最快方式。通过学习本书,读者可以快速、高效地掌握PHP和MySQL,成为一位构建Web站点的高手。 本书适合初中级Web应用开发和设计人员阅读。 本书是讲述PHP和MySQL技术的畅销书,以深入......一起来看看 《PHP 6与MySQL 5基础教程》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具