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

--config
    Specify an alternative configuration file path instead of the default.

--sync
    Synchronize only a specific account defined in the configuration file.

--all
    Synchronize all accounts defined in the configuration file.

--folder
    Synchronize only a specific folder within an account, if supported by the configuration.

--quick
    Perform a faster synchronization by primarily checking for new messages and skipping existing ones.

--keep-alive
    Keep the IMAP connection alive for continuous synchronization, especially useful in daemon mode.

--daemon
    Run offlineimap in the background as a daemon process, continuously synchronizing.

--timeout
    Set a timeout for network operations to prevent indefinite hangs.

--debug
    Enable verbose debugging output, useful for troubleshooting issues.

--version
    Display the offlineimap version information and exit.

--help
    Show a help message with available options and exit.

DESCRIPTION

offlineimap is a powerful and flexible command-line utility designed for bidirectional synchronization of IMAP mailboxes with local maildirs or Mailboxes. It allows users to access their emails offline, make changes (like marking as read, deleting, or moving messages), and have these changes synchronized back to the IMAP server. This tool is particularly useful for mobile users, those with unreliable internet connections, or anyone who desires a local backup of their email. It handles attachments, flags, and folder structures, ensuring a consistent state between the server and the local machine. Configuration is typically managed via a ~/.offlineimaprc file, providing granular control over accounts, folders, and synchronization behaviors, including scheduling and error handling. Its design allows for complex setups, including syncing multiple accounts and filtering specific folders.

CAVEATS

Large mailboxes or frequent synchronization can consume significant network bandwidth and local disk space. Configuration can be complex due to its flexibility, requiring careful setup of passwords and folder mappings, often with security considerations for password storage. Issues may arise with specific IMAP server implementations or non-standard behaviors. Running in daemon mode requires proper process management, error logging, and resource monitoring.

CONFIGURATION FILE

The primary way to configure offlineimap is through a configuration file, typically located at ~/.offlineimaprc or in ~/.config/offlineimap/config. This file uses an INI-like syntax to define accounts, remote and local repositories, folder filters, synchronization options, and hooks for custom actions. It's crucial for defining how emails are fetched, stored, and synchronized bidirectionally, supporting multiple accounts and complex filtering rules.

COMMON USAGE PATTERNS

Common usage patterns for offlineimap include:

  • As a one-shot command: Running `offlineimap` (or `offlineimap --all`) to sync all configured accounts once, often manually or triggered by an event.
  • As a cron job: Scheduled to run periodically (e.g., every 5-15 minutes) to keep local mailboxes relatively up-to-date with server changes.
  • As a daemon: Using `offlineimap --daemon` to continuously monitor for changes and synchronize in the background, providing near real-time updates. This mode requires careful configuration of logging and error handling.

HISTORY

offlineimap has been under active development for many years, primarily written in Python. It emerged as a robust and flexible solution for offline IMAP access, providing a reliable way to manage email locally. Its longevity and comprehensive feature set have made it a staple in the command-line email ecosystem, particularly for users leveraging text-based email clients like mutt or neomutt, contributing significantly to the ability to work with email even without a constant internet connection.

SEE ALSO

isync(1), mbsync(1), fetchmail(1), mail(1), mutt(1)

Copied to clipboard