GetMail sync all mailboxes IMAP

,

There’s a related feature request (even if title says pop3) where a user tried to do a PR but faced some problems:

Of course the mail package have changed since then. I think an option to retrieve ALL mailboxes folders could be considered for cockpit UI, unless it has and undesired behavior:

All IMAP retriever types also take the following optional parameters:

  • mailboxes (tuple of quoted strings) — a list of mailbox paths to retrieve mail from, expressed as a Python tuple. If not specified, the default is to retrieve mail from the mail folder named INBOX. You might want to retrieve messages from several different mail folders, using a configuration like this:

mailboxes = ("INBOX", "INBOX.spam", "mailing-lists.model-railroading")

Note that the format for hierarchical folder names is determined by the IMAP server, not by getmail. Consult your server’s documentation or postmaster if you’re unsure what form your server uses. If your mailbox names contain non-ASCII characters, ensure that your getmailrc file is stored with UTF-8 encoding so that getmail can correctly determine the unicode character names that need to be quoted in IMAP’s modified UTF-7 encoding; if you do not do this, the mailbox names will not match what the server expects them to be, or will cause UnicodeErrors when attempting to load your getmailrc file. As a special case, in getmail version 4.29.0 and later, the unquoted base (non-tuple) value ALL (case-sensitive) means to retrieve mail from all selectable IMAP mailboxes in the account. To retrieve messages from all mailboxes, you would use:

mailboxes = ALL