Download all emails from IMAP server, and save email to .eml files. And allow you restore these emails to a new imap server.
Project description
imapbackup
Download all emails from IMAP server, and save email to .eml files. And allow you restore these emails to a new imap server.
Install
pip install imapbackup
Usage
main
test@test emailbackup % imapbackup
Usage: imapbackup [OPTIONS] COMMAND [ARGS]...
Options:
--username TEXT IMAP account username. [required]
--password TEXT IMAP account password. [required]
--host TEXT IMAP server host. [required]
--port INTEGER IMAP server port, default to 993 if SSL is
enabled and default to 143 if SSL is not
enabled.
--ssl / --no-ssl Enable ssl.
--ssl-ciphers TEXT SSL ciphers used to make SSL connection.
--connection-timeout INTEGER Connection timeout.
--loglevel [DEBUG|INFO|WARN|ERROR]
--logfmt [default|simple|message_only]
--help Show this message and exit.
Commands:
backup Backup folders from IMAP server.
list List all folders of the IMAP server.
restore Restore all backup email files to IMAP server.
upload Upload eml to IMAP server.
backup
test@test emailbackup % imapbackup --host <imap.server.address> --ssl --username <username> --password <password> backup --help
Usage: imapbackup backup [OPTIONS] [FOLDER]...
Backup folders from IMAP server. If no folder given, then backup all
folders.
Data save structure:
----------------------------------------------------------
<Dest>
<MailFolder 1>
<mail_uid>-<mail_date>-<subject>-<mail_code>.eml
<MailFolder ...>
<mail_uid>-<mail_date>-<subject>-<mail_code>.eml
----------------------------------------------------------
<Dest>: is your data storage root. Given by option -d.
<MailFolder>: is the folder name from the IMAP server.
<mail_uid>: is the mail's UID from the IMAP server.
<mail_date>: is the mail's INTERNALDATE from the IMAP server.
<subject>: is the mail's Subject. We replace slash “/” sign to underline "_"
sign.
<mail_code>: is the sha1 hash code of the mail's BODY.
----------------------------------------------------------
Options:
-l, --limit INTEGER Fetch limit.
-d, --dest TEXT Dest folder. Data storage root. Default to ./data/.
--help Show this message and exit.
list
test@test emailbackup % imapbackup --host <imap.server.address> --ssl --username <username> --password <password> list --help
Usage: imapbackup list [OPTIONS]
List all folders of the IMAP server.
Options:
--folder-name-max-length INTEGER
--folder-name-mask TEXT
--help Show this message and exit.
restore
test@test emailbackup % imapbackup --host <imap.server.adddress> --ssl --username <username> --password <password> restore --help
Usage: imapbackup restore [OPTIONS] BACKUP_ROOT
Restore all backup email files to IMAP server.
Options:
--help Show this message and exit.
upload
test@test emailbackup % imapbackup --host <imap.server.adddress> --ssl --username <username> --password <password> upload --help
Usage: imapbackup upload [OPTIONS] DATA...
Upload eml to IMAP server.
Options:
-f, --folder TEXT Upload eml to this folder. The folder MUST be created
already. Default to INBOX.
--help Show this message and exit.
Example
- backup imap server.
imapbackup --host <imap.server.address> --ssl --username username01@example.com --password 'Password!' --loglevel=DEBUG backup --dest 'username01@example.com'
-
Your IMAP server address is
<imap.server.address>
, and using ssl connection, so that the imap server port is 993. -
Your email adddress is
username01@example.com
and your password isPassword!
. -
Write process log to
logs/app.log
, and set the log level to DEBUG. -
Save the backup emails under folder
username01@example.com
, group by IMAP folder, e.g. INBOX, 已发送. -
restore the backup data.
imapbackup --host <imap.server.address> --ssl --username username01@example.com --password 'Password!' --loglevel=DEBUG restore 'username01@example.com'
- Upload all emails under folder
username01@example.com
to the IMAP server. - Mostly the emails are created by
imapbackup
command.
Release
v0.1.0
- First release.
v0.1.1
- Fix python 3.8 and below, imaplib.IMAP4 and imaplib.IMAP4_SSL doesn't support timeout parameter problem.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file imapbackup-0.1.1.tar.gz
.
File metadata
- Download URL: imapbackup-0.1.1.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e282f3d4a6002dbb9bc33c8fac35bc9e1d549c54270d85103a064a5eccd98bab |
|
MD5 | 80ee23f3222d25c492f9c9f3cbf923a3 |
|
BLAKE2b-256 | 986b3fd7b87f0dcab86c74ab0f1e70ffdfbb852a3a7ee1a229df946e5b412970 |
File details
Details for the file imapbackup-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: imapbackup-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb3c38cebe4a5b963bbef37f7bf4e510c6b525ec3873080d9fd169320c3d92b3 |
|
MD5 | aae57f80ca1f5100b934cc8ad7a62212 |
|
BLAKE2b-256 | 098df9279a1ed0a1fd11e833089d09a37f776de8a821a0a04683478e56574837 |