Dovecot: imap Error: open (/var/mail/username) failed

  • by

Error

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

1.0 Solution

The Dovecot configuration file is /etc/dovecot/dovecot.conf. This file has a line,

!include conf.d/*.conf

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.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

You may like these, also

  • POSIX message queues in LinuxPOSIX message queues in Linux 1.0 POSIX Message queues POSIX interprocess comunication (IPC) was introduced in the POSIX.1b standard (IEEE Std 1003.1b-1993) for real time…
  • POSIX Shared Memory in LinuxPOSIX Shared Memory in Linux 1.0 Shared Memory Shared memory is the fastest method of interprocess communication (IPC) under Linux and other Unix-like systems. The…
  • POSIX Semaphores in LinuxPOSIX Semaphores in Linux 1.0 Semaphores Semaphores are used for process and thread synchronization. Semaphores are clubbed with message queues and shared memory under…
  • fork and exec system calls in Linuxfork and exec system calls in Linux 1.0 fork and exec system calls Suppose we wish to write a "shell program" which would execute another program. Now,…
  • Connecting two computers with Ethernet LAN cableConnecting two computers with Ethernet LAN cable Quite often, we wish to connect two computers back to back using an Ethernet LAN cable. It may be because…
  • D-Bus TutorialD-Bus Tutorial 1.0 D-Bus D-Bus is a mechanism for interprocess communication under Linux and other Unix-like systems. D-Bus has a layered architecture.…
  • Socket programming using the select system callSocket programming using the select system call 1.0 Client-Server Paradigm The Client-Server paradigm divides the software architecture of a system in two parts, the server and its…
  • System V message queues in LinuxSystem V message queues in Linux 1.0 Message queues Message queues are one of the interprocess communication mechanisms available under Linux. Message queues, shared memory and…
  • POSIX Threads Synchronization in CPOSIX Threads Synchronization in C 1.0 POSIX Threads Synchronization POSIX Threads provide multiple flows of execution within a process. The threads have their own stacks…
  • System V Shared Memory in LinuxSystem V Shared Memory in Linux 1.0 Shared Memory Shared memory is one of the three interprocess communication (IPC) mechanisms available under Linux and other Unix-like…