

IMAP Email Backup
source link: https://smalldata.tech/blog/2020/04/07/imap-email-backup
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.

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 ~/[email protected] -s imap.mail.server -S -p 993 -u [email protected] -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 ~/[email protected] ~/[email protected] # encrypt (could take a while) gpg -c ~/[email protected] # delete original rm ~/[email protected] rm -rf ~/[email protected] # decrypt gpg ~/[email protected] # extract tar -xvf ~/[email protected]
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 ~/[email protected]/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!
Recommend
-
22
With the new year upon us, I decided it was time to do something ambitious for my Open Source project. This is where I normally quip about never mentioning my project before, even though I literally always do. A new year...
-
11
渗透基础——利用IMAP协议读取邮件 22 Jan 20210x00 前言 在渗透测试中,当我们获得了用户的邮箱凭据,需要对邮箱内容进行分析时,可以选择通过IMAP协议实现自动化来提高效率。 本文以Exchange为例,介绍通过IMAP协议下载邮件...
-
16
Sending IMAP commands using php advertisements I'm trying to access yahoo mail IMAP server with a php script. I read that yahoo requires a spe...
-
6
【程式範例】使用Gmail IMAP讀取信件 2011-01-18 05:59 AM 26 27,528 工作上有從Gmail讀信取出附檔的需求,先前在點部落
-
8
What Google protocol does it use for Gmail? (not IMAP or POP) advertisements You can access gmail either using the web interface, Google's And...
-
13
如何正确设置QQ邮箱IMAP服务 2021年10月20日 132点热度 0人点赞...
-
4
How to Retrieve Emails Using IMAP in Python I am FSD (Full-stack developer) and I have expertise with Angular ,PHP, Node JS, Laravel, Codeigniter and front end. Location...
-
18
imap-backup Backup GMail (or other IMAP) accounts to disk Installation $ gem install 'imap-backup' Commands For a full list, run $ imap-backup help
-
21
Imap_search () unknown search criteria & ldquo; OR & rdquo; advertisements Trying to build a IMAP Search query to filter...
-
2
The Difference between POP3 Vs. IMAP EmailsThe Difference between POP3 Vs. IMAP EmailsWhen it comes to retrieving email messages, you have to do it right. To regain your emails, you need to be intentional which the method you pick on...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK