LinuxCommandLibrary

offlineimap

Synchronize email between local and remote mailboxes

TLDR

Synchronize once, without enabling autorefresh

$ offlineimap -o
copy

Synchronize a specific account
$ offlineimap -a [account]
copy

Synchronize a specific folder
$ offlineimap -f [folder]
copy

SYNOPSIS

offlineimap [options]

PARAMETERS

-a ACCOUNT, --account ACCOUNT
    Sync only the specified account(s)

-A, --allaccounts
    Sync all accounts (default)

-c FILE, --config FILE
    Use alternate config file

-d LEVEL, --debug LEVEL
    Set debug level (0-5)

-h, --help
    Show help message

-l LEVEL, --logfile LEVEL
    Set logging level (1-5)

-n, --no-threads
    Disable threading

-o, --one
    Run once and exit (no loop)

-P, --profiling
    Enable profiling

-q, --quiet
    Suppress non-error output

-r, --release
    Release all locks

-u, --update
    Update once without looping

-v, --verbose
    Increase verbosity

-V, --version
    Show version info

-1, --single-run
    Synonym for -o

DESCRIPTION

OfflineIMAP is a Python-based tool designed to synchronize email between an IMAP server and local folders, providing seamless offline access to mail. It supports Maildir and MH local formats, works with any IMAP-compatible server (e.g., Gmail, Outlook, Fastmail), and performs bidirectional syncing of emails, flags, and read status.

Key features include multi-threaded synchronization for speed, automatic handling of UID validity, filtering integration (e.g., with procmail or sieve), and robust locking to prevent corruption. Configuration is done via an INI-style ~/.offlineimaprc file, defining Repository sections for remote/local storage and Account sections linking them. It excels in cron jobs for periodic syncs, making it ideal for terminal-based email clients like mutt or neomutt.

OfflineIMAP ensures quick initial syncs and efficient updates, with options for dry runs, debugging, and selective account syncing. It's lightweight, extensible via Python hooks, and widely used in Linux workflows for privacy-focused, server-independent email management.

CAVEATS

Requires Python 3.8+; misconfigured sync can cause loops or data loss—test with dry-run. Locks prevent concurrent runs but may need manual release. Gmail requires app-specific passwords.

CONFIGURATION FILE

INI-style ~/.offlineimaprc with [Repository remote] (type=IMAP, remotehost=...), [Repository local] (type=Maildir, localfolders=...), and [Account mymail] linking them. See offlineimap(1) manpage.

USAGE TIP

Run via cron: 0 * * * * /usr/bin/offlineimap -q -u for hourly quiet updates.

HISTORY

Developed by John Goerzen in 2002 as a Perl tool, rewritten in Python. Maintained by community since 2010s; major v7-v8 releases (2020+) added async IMAP, Python 3 support, and threading improvements. Widely used in FOSS email stacks.

SEE ALSO

mbsync(1), isync(1), mutt(1), notmuch(1), imapfilter(1)

Copied to clipboard