All Projects → polo2ro → Imapbox

polo2ro / Imapbox

Licence: mit
Dump imap inbox to a local folder in a regular backupable format: html, json and attachements

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Imapbox

Imap Backup
Backup GMail (or other IMAP) accounts to disk
Stars: ✭ 522 (+383.33%)
Mutual labels:  backup, imap
Imapbackup
A Python script for incremental backups of IMAP mailboxes
Stars: ✭ 156 (+44.44%)
Mutual labels:  backup, imap
Xsrv
[mirror] Install and manage self-hosted services/applications, on your own server(s) - ansible collection and utilities
Stars: ✭ 89 (-17.59%)
Mutual labels:  backup
Telegram Cli Backup
A simple Lua script to backup Telegram messages into a CSV or sqlite database
Stars: ✭ 101 (-6.48%)
Mutual labels:  backup
Gemini
Automated backups of PersistentVolumeClaims in Kubernetes using VolumeSnapshots
Stars: ✭ 99 (-8.33%)
Mutual labels:  backup
Opaquemail
.NET email library and proxy supporting IMAP, POP3, and SMTP with S/MIME and PGP.
Stars: ✭ 91 (-15.74%)
Mutual labels:  imap
Pitrery
PostgreSQL Point In Time Recovery made easy
Stars: ✭ 99 (-8.33%)
Mutual labels:  backup
Xenon
Create backups of your discord server
Stars: ✭ 90 (-16.67%)
Mutual labels:  backup
Paperify
Minimal PaperBackup for large files using qrcodes.
Stars: ✭ 107 (-0.93%)
Mutual labels:  backup
Roam2github
Automatic backups from Roam Research into your private GitHub repo
Stars: ✭ 95 (-12.04%)
Mutual labels:  backup
Backup My Github
Clones all your repositories to local machine
Stars: ✭ 101 (-6.48%)
Mutual labels:  backup
Bups
Simple GUI for Bup, a very efficient backup system.
Stars: ✭ 94 (-12.96%)
Mutual labels:  backup
Snebu
Simple Network Encrypting Backup Utility
Stars: ✭ 92 (-14.81%)
Mutual labels:  backup
Laravel Backup Server
Backup multiple servers
Stars: ✭ 100 (-7.41%)
Mutual labels:  backup
Content Lambda Boto3
Automating AWS with Lambda, Python, and Boto3
Stars: ✭ 91 (-15.74%)
Mutual labels:  backup
Zmbackup
A reliable software written in Shell Script to help you in your daily task to backup and restore mails and accounts from Zimbra Open Source Email Platform. Project in deprecation process. Please help me with Waddles.
Stars: ✭ 103 (-4.63%)
Mutual labels:  backup
Inbrief
InBrief is a personal briefing app and dashboard powered by Electron and React
Stars: ✭ 90 (-16.67%)
Mutual labels:  imap
Gitbackup
Tool to backup your GitHub and GitLab repositories
Stars: ✭ 94 (-12.96%)
Mutual labels:  backup
Etcd Backup Restore
Collection of components to backup and restore the Etcd of a Kubernetes cluster
Stars: ✭ 99 (-8.33%)
Mutual labels:  backup
Conserve
[beta] robust portable backup tool in Rust
Stars: ✭ 107 (-0.93%)
Mutual labels:  backup

IMAPBOX

Dump IMAP inbox to a local folder in a regular backupable format: HTML, PDF, JSON and attachments.

This program aims to save a mailbox for archive using files in indexable or searchable formats. The produced files should be readable without external software, for example, to find an email in backups using only the terminal.

For each email in an IMAP mailbox, a folder is created with the following files:

File Description
message.html If an html part exists for the message body. the message.html will always be in UTF-8, the embedded images links are modified to refer to the attachments subfolder.
message.pdf This file is optionally created from message.html when the wkhtmltopdf option is set in the config file.
attachments The attachments folder contains the attached files and the embeded images.
message.txt This file contain the body text if available in the original email, always converted in UTF-8.
metadata.json Various informations in JSON format, date, recipients, body text, etc... This file can be used from external applications or a search engine like Elasticsearch.
raw.eml.gz A gziped version of the email in .eml format.

Imapbox was designed to archive multiple mailboxes in one common directory tree, copies of the same message spread knew several account will be archived once using the Message-Id property.

Install

This script requires Python 3 for master branch or python 2 on the python2 branch and the following libraries:

  • six
  • chardet – required for character encoding detection.
  • pdfkit – optionally required for archiving emails to PDF.

Use cases

  • I use the script to merge all my mail accounts in one searchable directory on my NAS server.
  • Report on a website the content of an email address, like a mailing list.
  • Sharing address of several employees to perform cross-searches on a common database.
  • Archiving an IMAP account because of mailbox size restrictions, or to restrain the used disk space on the IMAP server.
  • Archiving emails to PDF format.

Config file

Use ~/.config/imapbox/config.cfg or /etc/imapbox/config.cfg

Example:

[imapbox]
local_folder=/var/imapbox
days=6
wkhtmltopdf=/opt/bin/wkhtmltopdf

[account1]
host=mail.autistici.org
username=[email protected]
password=secret

[account2]
host=imap.googlemail.com
username=[email protected]
password=secret
remote_folder=INBOX
port=993

The imapbox section

Possibles parameters for the imapbox section:

Parameter Description
local_folder The full path to the folder where the emails should be stored. If the local_folder is not set, imapbox will download the emails in the current directory. This can be overwritten with the shell argument -l.
days Number of days back to get in the IMAP account, this should be set greater and equals to the cronjob frequency. If this parameter is not set, imapbox will get all the emails from the IMAP account. This can be overwritten with the shell argument -d.
wkhtmltopdf (optional) The location of the wkhtmltopdf binary. By default pdfkit will attempt to locate this using which (on UNIX type systems) or where (on Windows). This can be overwritten with the shell argument -w.

Other sections

You can have has many configured account as you want, one per section. Sections names may contains the account name.

Possibles parameters for an account section:

Parameter Description
host IMAP server hostname
username Login id for the IMAP server.
password (optional) The password will be saved in cleartext, for security reasons, you have to run the imapbox script in userspace and set chmod 700 on your ~/.config/mailbox/config.cfg file. The user will prompted for a password if this parameter is missing.
remote_folder (optional) IMAP folder name (multiple folder name is not supported for the moment). Default value is INBOX. You can use __ALL__ to fetch all folders.
port (optional) Default value is 993.

Metadata file

Property Description
Subject Email subject
Body A text version of the message
From Name and email of the sender
To An array of recipients
Cc An array of recipients
Attachments An array of files names
Date Message date with the timezone included, in the RFC 2822 format
Utc Message date converted in UTC, in the ISO 8601 format. This can be used to sort emails or filter emails by date
WithHtml Boolean, if the message.html file exists or not
WithText Boolean, if the message.txt file exists or not

Elasticsearch

The metadata.json file contain the necessary informations for a search engine like Elasticsearch. Populate an Elasticsearch index with the emails metadata can be done with a simple script.

Create an index:

curl -XPUT 'localhost:9200/imapbox?pretty'

Add all emails to index:

#!/bin/bash
cd emails/
for ID in */ ; do
    curl -XPUT "localhost:9200/imapbox/message/${ID}?pretty" --data-binary "@${ID}/metadata.json"
done

A front-end can be used to search in email archives:

  • Calaca is a beautiful, easy to use, search UI for Elasticsearch.
  • Facetview

Search in emails without indexation process

jq is a lightweight and flexible command-line JSON processor.

Example command to browse emails:

find . -name "*.json" | xargs cat | jq '[.Date, .Id, .Subject, " ✉ "] + .From | join(" ")'

Example with a filter on UTC date:

find . -name "*.json" | xargs cat | jq 'select(.Utc > "20150221T130000Z")'

Docker compose

version: '3'
services:

  imapbox:
    image: mauricemueller/imapbox
    container_name: imapbox
    volumes:
      - imapbox_data:/var/imapbox
      # change the path to the config
      - ./test/config.cfg:/etc/imapbox/config.cfg

volumes:
  imapbox_data:

docker-compose run --rm imapbox

Similar projects

NoPriv is a python script to backup any IMAP capable email account to a browsable HTML archive and a Maildir folder.

License

The MIT License (MIT)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].