mbsync is a command line application which synchronizes mailboxes; currently Maildir and IMAP4 mailboxes are supported. New messages, message deletions and flag changes can be propagated both ways; the operation set can be selected in a fine-grained manner.
apt-get install isync
Assuming that you want to sync the mails of
firstname.lastname@example.org and that you have your password stored in
IMAPAccount example Host examplehost.com User "email@example.com" PassCmd "/usr/bin/pass mail/example" IMAPStore example-remote Account example UseNamespace no MaildirStore example-local Path ~/mail/example/ Inbox ~/mail/example/Inbox Channel example Master :example-remote: Slave :example-local: Create Both Patterns * SyncState * CopyArrivalDate yes Sync Pull
You need to manually create the directories where you store the emails.
mkdir -p ~/mail/example