GetMail sync all mailboxes IMAP


NethServer Version: NethServer release 7.6.1810 (3.10.0-957.21.2.el7.x86_64)
Module: Getmail

Hi, guys,
I have configured it from the dashboard but I see that it only downloads me the INBOX folder. Of the other folders there is no trace. Where can I find the getmail configuration file so that it can be modified with “mailboxes = ALL”?

I think that… it will need a feature.

As default, getmail downloads only the INBOX.
The configuration files are saved inside: /var/lib/getmail.

You can create a custom template for your usage scenario (I didn’t tested it, but it should work):

mkdir -p /etc/e-smith/templates-custom/getmailrc/
echo mailboxes = ALL > /etc/e-smith/templates-custom/getmailrc/90mailboxes
signal-event nethserver-getmail-save

il mio file getmail è cosi composto…

type = SimpleIMAPRetriever
server =
username = *myaccountmail*
password = *password*

type = MDA_external
path = /usr/libexec/dovecot/dovecot-lda
arguments = ("-e","-d","")
user = vmail
group = vmail

# rspamd filter checks are disabled

read_all = false
delete = false
received = false
message_log_syslog = true
delivered_to = false

**mailboxes = ALL**

dovrebbe essere già abilitatò il fatto che scarica tutto l’account…
ho seguito prima la procedura che mi hai dato.

Please write in English so anyone can understand.

So the template-custom worked well, everything is good!

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

the fact is that on webtop I can not see the folders. I have not tried with an email client…

Lory temo sia lo stesso problema che avevo io: "mailboxes = ALL " mi prelevava la posta da tutti i subfolders lato provider (inbox, sent, bozze, spam, etc…) ma mi salvava TUTTA la posta in INBOX lato server, invece di ricreare la stessa struttura. Per questo problema dovetti cambiare completamente sistema e rinunciare a nethserver.

Lory I fear it is the same problem that I had: “mailboxes = ALL” picked up the mail from all the subfolders on the provider side (inbox, sent, drafts, spam, etc …) but it saved/stored ALL the mail in INBOX folder nethserver side, instead to recreate the same structure. For this problem I had to completely change system and give up on nethserver.

ciao @Computer_Doctor , si non vedo la stessa struttura e penso che mi salvi tutto nella INBOX come mi segnali, dopo aver attivato “mailboxs = ALL” vedo un sacco di messaggi in entrata.
Eh peccato però, NS mi piace assai.

hello @Computer_Doctor , you do not see the same structure and I think it saves me everything in the INBOX as you signal me, after activating “mailboxs = ALL” I see a lot of incoming messages.
Too bad though, I like NS a lot.

Exactly, if you read my original post you will see that I had reported this problem some time ago and the answers were not helpful. In the meantime I have received notifications of improvements and implementations, but I fear that not much has changed in this regard. The only thing you should try / verify is the nomenclature of the folders (on the provider side and locally) … and possibly try to manually force the same structure locally (or use aliases). Obviously it is important that Dovecot is configured well otherwise it messes up.
Alternatively you could use a great Getmail or Impasync TOGETHER with Nethserver (even on separate or virtual machines) … it is certainly a hybrid and requires medium to high skills but it works and I have tried it for myself.

IMHO and theorycally: if there is an option to synchronize/fetch ALL folders, there must also be:
a) a function that recreates the folders locally
b) “something” (like rules) which establishes in which folder or sub-folder the mail is placed
IF you find A or B (and work on it) you’ve got the solution. But anyone here answered this so far.

From getmail mailing list:

You can actually do this if you use MDA_external and the %(mailbox) substitution. Note you can use getmail’s included mbox or maildir MDA scripts, you don’t have to use a 3rd-party one. You’ll have to ensure the destination maildirs or mbox files exist before trying to deliver to them, of course.

But if you’re looking for a single setting to just say “replicate the IMAP structure from there to here”, getmail isn’t designed to do that. There are other tools that are; some people mention imapsync.

I forgot to mention the other solution that I’ve used in the past. You can run getmail with multiple rc files; just specify the folders to retrieve from manually (rather than using ALL) and specify a different destination in each rc file.

mailboxes = (“model-railroading”, )

type = Maildir
path = ~/Mail/hobbies/railroads/

mailboxes = (“work”, )

type = Maildir
path = ~/Mail/inbox/

… and then running getmail with multiple rc files.

the debian packaging for getmail actually includes such a wrapper shell script, called “getmails”.

you might be able to get dovecot sieve to read the folder name from the X-getmail-retrieved-from-mailbox header and file automatically creating missing folders as it goes. It would rely on some sieve extensions that I don’t use, so I’m not sure.

1 Like