# OfflineIMAP

> 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 (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: https://www.offlineimap.org/
- Source: https://github.com/OfflineIMAP/offlineimap3
- Documentation: https://www.offlineimap.org/documentation.html

## Install

### Linux

Native.

- apt: `sudo apt install offlineimap3`
- dnf: `sudo dnf install offlineimap`
- pacman: `sudo pacman -S offlineimap`
- pipx: `pipx install offlineimap`

### macOS

Native.

- Homebrew: `brew install offlineimap`
- pipx: `pipx install offlineimap`

### Windows

Through WSL. No native Windows package; use WSL.

- WSL: `sudo apt install offlineimap3`

### BSD

Native.

- FreeBSD pkg: `pkg install mail/py-offlineimap`
- OpenBSD: `pkg_add offlineimap`

### Android

Not supported.

## Protocols

- IMAP: Yes
- POP3: No
- SMTP: No
- JMAP: No
- Maildir: Yes
- mbox: No
- notmuch: No

## Features

- OpenPGP: No
- S/MIME: No
- OAuth2 sign-in: Yes
- Threads: No
- Search: No
- HTML mail: No
- Mouse: No
- Multiple accounts: Yes
- Offline use: keeps a full local Maildir copy
- Calendar: No
- Contacts: No
- Vim-style keys: No
- Configuration: ~/.offlineimaprc or ~/.config/offlineimap/config (INI)

## 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

File: `~/.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]
```

| Protocol | Server | Port | Security |
| --- | --- | --- | --- |
| IMAP | imap.forwardemail.net | 993 | SSL/TLS |
| POP3 | pop3.forwardemail.net | 995 | SSL/TLS |
| SMTP | smtp.forwardemail.net | 465 | SSL/TLS |
| SMTP | smtp.forwardemail.net | 587 | STARTTLS |

Username: your full alias address. Password: the one from Generate Password next to the alias. Folders: INBOX, Drafts, Sent Mail, Trash, Spam and Archive.

## 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

- https://www.offlineimap.org/
- https://github.com/OfflineIMAP/offlineimap3
- https://github.com/OfflineIMAP/offlineimap3/blob/master/README.md
- https://github.com/OfflineIMAP/offlineimap3/blob/master/offlineimap.conf
- https://github.com/OfflineIMAP/offlineimap3/blob/master/pyproject.toml
- https://github.com/OfflineIMAP/offlineimap
- https://pypi.org/project/offlineimap/
- https://packages.debian.org/search?keywords=offlineimap3&searchon=names&exact=1
- https://packages.ubuntu.com/offlineimap3
- https://mdapi.fedoraproject.org/rawhide/pkg/offlineimap
- https://archlinux.org/packages/extra/any/offlineimap/
- https://formulae.brew.sh/formula/offlineimap
- https://www.freshports.org/mail/py-offlineimap/
- https://openports.pl/path/mail/offlineimap
