Last Updated on
While configuring mail on a Ubuntu Linux server running the Postfix mail server and Dovecot IMAP server, the following errors were observed in the mail log files,
dovecot: imap(user1): Error: open(/var/mail/user1) failed: Permission denied (euid=1002(user1) egid=1002(user1) missing +w perm: /var/mail, we're not in group 8(mail), dir owned by 0:8 mode=0775) dovecot: imap(user1): Error: Failed to autocreate mailbox INBOX: Internal error occurred. Refer to server log for more information
The Dovecot configuration file is /etc/dovecot/dovecot.conf. This file has a line,
which causes inclusion of all files with names ending with .conf in the /etc/dovecot/conf.d directory. The file names start with numbers like, 10, 20, 30, etc., which determines the order in which the files are combined. So, a configuration entry in a file can be overruled by another entry in a later file. The above error is caused by the configuration entry,
mail_location = mbox:~/mail:INBOX=/var/mail/%u
in the /etc/dovecot/conf.d/10-mail.conf file. This indicates that the mailbox to be used for mail retrieval by clients lies in the /var/mail/<username> directory. The actual mailbox to be used for mail retrieval was under Maildir in the user's home directory. The solution involved changing the above line to
mail_location = maildir:~/Maildir
2.0 Getting Dovecot configuration
Since the Dovecot configuration is split across so many files, it would be helpful if we get the full existing configuration via a single command. The command, dovecot -n does just that.
$ dovecot -n # 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf # Pigeonhole version 0.4.13 (7b14904) # OS: Linux 4.5.0-x86_64-linode65 x86_64 Ubuntu 16.04 LTS auth_mechanisms = plain login mail_location = maildir:~/Maildir managesieve_notify_capability = mailto ...
The -n option prints the non-default settings on the standard output. One suggestion is to put all these settings in /etc/dovecot/dovecot.conf and remove the line including files in the conf.d directory. Another option is to put all the settings in a file with name starting with 99, like the file named 99-mail-stack-delivery.conf. As its name starts with
99, it will be assembled last in the configuration settings. The settings in this file would replace the ones given in
earlier files, having file names starting with smaller numbers.