Skip to main content

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

  1. backup imap server.
imapbackup --host <imap.server.address> --ssl --username username01@example.com --password 'Password!' --loglevel=DEBUG backup --dest 'username01@example.com'
  1. Your IMAP server address is <imap.server.address>, and using ssl connection, so that the imap server port is 993.

  2. Your email adddress is username01@example.com and your password is Password!.

  3. Write process log to logs/app.log, and set the log level to DEBUG.

  4. Save the backup emails under folder username01@example.com, group by IMAP folder, e.g. INBOX, 已发送.

  5. restore the backup data.

imapbackup --host <imap.server.address> --ssl --username username01@example.com --password 'Password!' --loglevel=DEBUG restore 'username01@example.com'
  1. Upload all emails under folder username01@example.com to the IMAP server.
  2. Mostly the emails are created by imapbackup command.

Release

v0.1.0

  • First release.

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

imapbackup-0.1.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

imapbackup-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file imapbackup-0.1.0.tar.gz.

File metadata

  • Download URL: imapbackup-0.1.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for imapbackup-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2cf6b69bb6fe0ff9ce814e622f8dbec711fd6f2dcca38535c3128642945ee2e
MD5 fe304b53d82e241fd06edda59293e590
BLAKE2b-256 ddf4bf0efb1a7dd6297e433671362d538ef09909525b030840a01f81046bbdd3

See more details on using hashes here.

File details

Details for the file imapbackup-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: imapbackup-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for imapbackup-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9cc0a39cd5be45192ac96e2769311c7c82afa0abec03e6343da735e49afa110
MD5 8b59259318ac845c449948255cd5b9b0
BLAKE2b-256 b7bd41dd2fcb637a3ddcfea9ac1ec67269129b05bd6000b1f6501e3302975555

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page