1

I have an Office 365 account who has multiple folders (mailboxes). With getmail I can retrieve all emails from all mailboxes with the following configuration:

[retriever]
type=SimpleIMAPSSLRetriever
server=<server>
port=<port>
username=<user>
password=<passwd>
mailboxes=ALL  

[destination]
type=Mboxrd
path=/var/mail/user
user=<user>

[options]
verbose=0
read_all=false
delete=false
delete_after=0
delete_bigger_than=0
max_bytes_per_session=0
max_message_size=0
max_messages_per_session=0
delivered_to=false
received=false
message_log=/home/user/getmail.log
message_log_syslog=false
message_log_verbose=true

It downloads all emails in /var/mail/user with format mbox. This format is supported by Dovecot 1. My configuration to get these emails from the mbox file and show them via Dovecot server is the following:

disable_plaintext_auth = no
mail_privileged_group = mail
mail_location = mbox:~/:INBOX=/var/mail/%u
ssl = no
protocols = "imap"
listen = 127.0.0.1
userdb {
  driver = passwd
}
passdb {
  args = %s
  driver = pam
}
protocol imap {
}

It works and shows all emails but the problem is that Dovecot does not know what is the mailbox of each email. I have looked in the mbox file, and I have seen that getmail adds the header X-getmail-retrieved-from-mailbox for each email. But when I access to dovecot via IMAP, I see all emails in the INBOX and not in each folder like Office 365. The MUA (Mail User Agent) that I am using is Roundcube. My question is how can I show all folders of Office 365 in Dovecot using getmail and the mbox format.

https://wiki2.dovecot.org/MailboxFormat/mbox

1 Answer 1

1

This is normal – each mbox file corresponds to exactly one mailbox (folder). Additional folders would need to be stored as individual mbox files under ~/ (according to your current Dovecot config).

After skimming through getmail documentation, it seems that getmail does not support dynamically creating destination mailboxes. (There are only "Multi" destinations which sort according to recipient address, but none which would sort according to source mailbox name.)

There are other tools which can clone all folders, for example:

  • imapsync (using IMAP→IMAP, i.e. uploading messages through Dovecot itself)
  • OfflineIMAP (using either IMAP→Maildir or IMAP→IMAP)

If you absolutely require the mbox storage format, use an IMAP→IMAP synchronization tool and let Dovecot handle updating the mbox file (as your configuration already does).

Consider also changing the folder location from ~/ to ~/Mail/, as otherwise Dovecot will need to scan your entire home directory just to determine what folders you have.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .