Terminal Email

OfflineIMAP

CLIMail tool

Python program that syncs IMAP mailboxes with local Maildir folders in both directions.

OfflineIMAP downloads IMAP folders into local Maildirs and keeps both sides in sync, so a Maildir client can read mail offline. The maintained code base is offlineimap3, the Python 3 port; the original Python 2 repository is no longer developed. Configuration is an INI-style file, and Python helper functions can supply passwords, folder name mapping and filters.

Type
Mail tool
Interface
Command-line tools and prompts
Systems
Runs on Linux, macOS and BSD, on Windows through WSL. Not available for Android.
Language
Python
License
GPL 2.0 or later
Latest version
8.0.3
Background
Python 3 port of the original OfflineIMAP (Python 2, no longer maintained)
Maintained
Yes
Website
offlineimap.org
Source
github.com/OfflineIMAP/offlineimap3
Documentation
offlineimap.org

Install

SystemSupportInstall
LinuxNative
aptsudo apt install offlineimap3
dnfsudo dnf install offlineimap
pacmansudo pacman -S offlineimap
pipxpipx install offlineimap
macOSNative
Homebrewbrew install offlineimap
pipxpipx install offlineimap
WindowsThrough WSL
WSLsudo apt install offlineimap3

No native Windows package; use WSL.

BSDNative
FreeBSD pkgpkg install mail/py-offlineimap
OpenBSDpkg_add offlineimap
AndroidNot supported-

Protocols and features

Protocols
ProtocolOfflineIMAP
IMAPYes
POP3No
SMTPNo
JMAPNo
MaildirYes
mboxNo
notmuchNo
Features
FeatureOfflineIMAP
OpenPGPNo
S/MIMENo
OAuth2 sign-inYes
ThreadsNo
SearchNo
HTML mailNo
MouseNo
Multiple accountsYes
Offline usekeeps a full local Maildir copy
CalendarNo
ContactsNo
Vim-style keysNo
Configuration~/.offlineimaprc or ~/.config/offlineimap/config (INI)

Pros and cons

Pros

  • Built-in XOAUTH2 support for Gmail and similar providers
  • Python hooks (pythonfile) for passwords, folder name mapping and filtering
  • Can sync accounts in parallel and run repeatedly with autorefresh

Cons

  • Slower than isync on large mailboxes
  • Older guides and some packages still point to the unmaintained Python 2 version
  • Only IMAP and Maildir; no POP3 and no sending

Use OfflineIMAP with Forward Email

How OfflineIMAP fits with a Forward Email mailbox. Replace you@example.com with your alias and the password command with your own. The same settings work with any provider once the server names change.

~/.offlineimaprc
[general]
accounts = forwardemail
pythonfile = ~/.offlineimap.py

[Account forwardemail]
localrepository = forwardemail-local
remoterepository = forwardemail-remote

[Repository forwardemail-local]
type = Maildir
localfolders = ~/Mail/forwardemail

[Repository forwardemail-remote]
type = IMAP
remotehost = imap.forwardemail.net
remoteport = 993
ssl = yes
sslcacertfile = OS-DEFAULT
remoteuser = you@example.com
remotepasseval = get_pass("forwardemail/you@example.com")

# ~/.offlineimap.py
# import subprocess
# def get_pass(name):
#     return subprocess.check_output(["pass", "show", name]).decode().splitlines()[0]
ProtocolServerPortSecurity
IMAPimap.forwardemail.net993SSL/TLS
POP3pop3.forwardemail.net995SSL/TLS
SMTPsmtp.forwardemail.net465SSL/TLS
SMTPsmtp.forwardemail.net587STARTTLS

Username: your full alias address, such as you@example.com. Password: the one shown by Generate Password next to the alias in your Forward Email account. Folders: INBOX, Drafts, Sent Mail, Trash, Spam and Archive.

Prefer no config at all? Forward Email's terminal app signs in with your account and has mail, calendar and contacts in one program.

Questions

Does OfflineIMAP work on Windows?

Not natively. It runs in Windows Subsystem for Linux (WSL). No native Windows package; use WSL.

Does OfflineIMAP support IMAP?

Yes, OfflineIMAP connects to IMAP servers directly.

Is OfflineIMAP open source?

Yes, under the GPL 2.0 or later.

How do I use OfflineIMAP with Forward Email?

Use the config in the Forward Email section on this page, saved as ~/.offlineimaprc, and replace the address and password with your own.

Sources