As a Linux user constantly switching between email clients (we've all been there with Evolution, Thunderbird, Mutt, etc.), maintaining a centralized email archive becomes critical. Proprietary solutions like MXsense don't give you the transparency or control that open source alternatives provide.
Here are battle-tested solutions with varying architectures:
- imapfw - Python-based IMAP synchronization tool
- Mailpiler - Full-featured archival system with web UI
- Archivemail - Command-line tool for mbox/Maildir
- OfflineIMAP - Two-way sync with local Maildir
This combo gives you both archiving and client flexibility. First install OfflineIMAP:
sudo apt-get install offlineimap # Debian/Ubuntu
sudo dnf install offlineimap # Fedora
Sample ~/.offlineimaprc configuration:
[general]
accounts = Archive
maxsyncaccounts = 2
[Account Archive]
localrepository = LocalArchive
remoterepository = RemotePOP3
[Repository LocalArchive]
type = Maildir
localfolders = ~/Mail/Archive
[Repository RemotePOP3]
type = POP3
remotehost = mail.example.com
remoteuser = your_email
remotepass = your_password
ssl = yes
maxconnections = 1
For regular archiving, set up a cron job:
# Run every 6 hours
0 */6 * * * /usr/bin/offlineimap -o -u quiet
If you need browser access to archived emails:
- Roundcube - Configure with your Maildir path
- Rainloop - Lightweight webmail alternative
- Mailpiler - Dedicated archival web interface
For Mailpiler installation:
wget https://www.mailpiler.org/download/mailpiler-1.3.7.tar.gz
tar xvfz mailpiler-1.3.7.tar.gz
cd mailpiler-1.3.7
./configure --prefix=/usr/local/mailpiler
make
sudo make install
For programmers who want more control, here's a basic POP3 archiver:
import poplib
from email import parser
def archive_pop3(server, user, password, output_dir):
mail = poplib.POP3_SSL(server)
mail.user(user)
mail.pass_(password)
num_messages = len(mail.list()[1])
for i in range(num_messages):
raw_email = b"\n".join(mail.retr(i+1)[1])
parsed_email = parser.Parser().parsestr(raw_email.decode())
with open(f"{output_dir}/msg_{i}.eml", "w") as f:
f.write(str(parsed_email))
archive_pop3("mail.example.com", "user", "password", "/path/to/archive")
As a long-time Linux user, I've struggled with the lack of an Outlook-caliber email client. The constant switching between clients like Thunderbird, Evolution, and Mutt made me realize the critical need for a centralized email archive solution that's:
- Protocol-agnostic (works with POP3/IMAP/Maildir)
- Open source and Linux-native
- Preferably web-accessible
After extensive testing, these solutions stood out:
1. MailPile (Python-based)
A modern solution with search-centric design. Example setup for Maildir:
# Install via pip
pip install mailpile
# Basic configuration
mailpile --setup
set mail.maildir = ~/Maildir
set ui.port = 33411
2. Archivemail (Python)
Lightweight script for periodic archiving:
# Archive emails older than 365 days
archivemail --days=365 --delete --compress ~/mail/Inbox
3. Dovecot + Sieve (Enterprise-grade)
For server-side filtering and archiving:
# /etc/dovecot/conf.d/90-sieve.conf
plugin {
sieve = ~/.dovecot.sieve
sieve_dir = ~/sieve
}
For those wanting browser access:
Roundcube with Archive Plugin
# Install plugin via composer
composer require roundcube/archiveplugin
MailArchiva Open Source Edition
Java-based solution with Lucene search:
# Startup script
java -Xmx1024m -jar mailarchiva.jar \
--http-port=8080 \
--data-dir=/var/mailarchiva
For maximum control, I recommend this cron-powered solution:
# ~/.offlineimaprc
[general]
accounts = Gmail
maxsyncaccounts = 2
[Account Gmail]
localrepository = Local
remoterepository = Remote
[Repository Local]
type = Maildir
localfolders = ~/Mail/Gmail
[Repository Remote]
type = IMAP
remotehost = imap.gmail.com
ssl = yes
Combine with a simple cron job:
# /etc/cron.hourly/email-archive
#!/bin/sh
/usr/bin/offlineimap -u quiet
When dealing with large archives:
- Use Maildir over mbox for better performance
- Consider SQLite-backed solutions for metadata
- Index attachments separately with tools like Apache Tika