Dovecot error reading mailbox: Can't expand ~/ for mail root

Solution 1:

There was two errors:

  • Exim mail format did not match with dovecot mail format, exim was using maildir, dovecot was configured with mbox. I had to change dovecot configuration to maildir.
  • Dovecot maildir configuration used full address as user folder, exim wrote its user folder only with user part of the address. Example: /var/mail/mydomain.com/[email protected] instead of /var/mail/mydomain.com/myuser

I had to change this configuration row in dovecot From:

mail_location = mbox:~/mail:INBOX=/var/mail/%d/%u

to

mail_location = maildir:/var/mail/%d/%n

(I underline the "maildir" prefix instead of "mbox" and the %n placeholder instead of %u)