7

I have tried configuring a Postfix/Dovecot combo with virtual users using this guide.

My server is running Postfix 2.6.6 and Dovecot 2.0.9 on CentOS 6.5.

The problem is that when I connect to the server using Outlook 2013 (it connects just fine on IMAP+SMTP) and send myself a test e-mail I don't receive the e-mail. Looking at the maillog I can see I'm getting the error

postfix/virtual[2768]: 9C3D480768: to=<user@domain.net>, relay=virtual, delay=1132, delays=1132/0.02/0/0.02, dsn=4.2.0, status=deferred (delivery failed to mailbox /var/vmail/domain.net/user: cannot open file: Is a directory)

The error message was pretty clear and I thought, well, this could be leftovers from a defect Cyrus/Postfix installation I had earlier. I went ahead and deleted the vmail folder, created a subfolder for the domain and changed the ownership of everything to vmail:vmail. I restart postfix and dovecot and the inbox directory appears again. Postfix continues to complain as it did before. Then I tried deleting the folder and then create an empty file, but this only made it a dovecot issue rather than a postfix issue, so now dovecot says it was expecting a file rather than a directory.

/etc/postfix/main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps

inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost

debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

relay_domains = *
virtual_alias_maps=hash:/etc/postfix/vmail_aliases
virtual_mailbox_domains=hash:/etc/postfix/vmail_domains
virtual_mailbox_maps=hash:/etc/postfix/vmail_mailbox

virtual_mailbox_base = /var/vmail
virtual_minimum_uid = 2222
virtual_transport = virtual
virtual_uid_maps = static:2222
virtual_gid_maps = static:2222

smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /var/run/dovecot/auth-client
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
smtpd_sasl_local_domain = $mydomain
broken_sasl_auth_clients = yes

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

/etc/dovecot/dovecot.conf

listen = *
ssl = no
protocols = imap lmtp
disable_plaintext_auth = no
auth_mechanisms = plain login
mail_access_groups = vmail
default_login_user = vmail
first_valid_uid = 2222
first_valid_gid = 2222
mail_location = maildir:/var/vmail/%d/%n

passdb {
    driver = passwd-file
    args = scheme=SHA1 /etc/dovecot/passwd
}
userdb {
    driver = static
    args = uid=2222 gid=2222 home=/var/vmail/%d/%n allow_all_users=yes
}
service auth {
    unix_listener auth-client {
        group = postfix
        mode = 0660
        user = postfix
    }
    user = root
}
service imap-login {
    process_min_avail = 1
    user = vmail
}

and finally some example entries in my domains/aliases/mailbox lists

domain.tld        OK # /etc/postfix/vmail_domains
user@domain.tld   domain.tld/user # /etc/postfix/vmail_mailbox
user@domain.tld   user@domain.tld # /etc/postfix/vmail_aliases
user@domain.tld:oOeIaLM/TyEPOdflb+GlL7d1MhE= # /etc/dovecot/passwd
  • 1
    You have a typo in your dovecot.conf, the first Maildir line should be commented out. – NickW Mar 6 '14 at 14:44
  • @NickW Thanks for pointing that out, although I did find the actual issue I didn't notice this. – Steen Schütt Mar 6 '14 at 22:09
  • No problems, those little oversights have cost me many an hour of fustration :) – NickW Mar 7 '14 at 9:04
13

The answer is extremely simple. The path in /etc/postfix/vmail_mailbox is missing a trailing slash. When there is no trailing slash, postfix will treat it as a file and thereby assume the mailbox is in Mailbox (and not Maildir) format.

By appending the trailing slash, postfix will correctly consider the directory to be of maildir format and treat it accordingly.

Example:

user@domain.tld   domain.tld/user/
user2@domain.tld   domain.tld/user2/
  • omg its so unfortunate i didnt see this three days ago... – garenyondem Oct 11 '17 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.