1

I have set up a mail server using Postfix, Dovecot and MySQL on a CentOS machine to serve some virtual users but for some reason it doesn't store emails in their proper folders. Postfix and Dovecot both use a system user called vmail with it's home directory set to /home/vmail

Domains and their associated email addresses are stored into a MySQL database and Postfix should create their mailboxes in /home/vmail.

Emails should be stored in folders following this format:

  • /home/vmail/example.com/sales/Maildir -> sales@example.com
  • /home/vmail/example.com/contact/Maildir -> contact@example.com

But regardless of their destination address they are all dumped into this folder:

  • /home/vmail/vmail/Maildir

Because of this accessing said mails using any email client is impossible. Everything else (authentication, sending/receiving emails) works, mails just aren't stored where they should.

A similar setup using Courier instead of Dovecot works as expected so I assume it's something related to Dovecot only.

Here is my dovecot configuration reduced to minimum:

protocols = imap pop3
log_timestamp = "%Y-%m-%d %H:%M:%S"
mail_location = maildir:/home/vmail/%d/%n/Maildir

ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
ssl_key = </etc/pki/dovecot/private/dovecot.pem

namespace {
    type = private
    separator = .
    prefix = INBOX.
    inbox = yes
}
service auth {
    unix_listener auth-master {
        mode = 0600
        user = vmail
    }
    unix_listener /var/spool/postfix/private/auth {
        mode = 0666
        user = postfix
        group = postfix
    }
    user = root
}
service auth-worker {
    user = root
}
protocol lda {
    log_path = /home/vmail/dovecot-deliver.log
    auth_socket_path = /var/run/dovecot/auth-master
    postmaster_address = postmaster@example.com
}
protocol pop3 {
    pop3_uidl_format = %08Xu%08Xv
}
passdb {
    driver = sql
    args = /etc/dovecot/dovecot-sql.conf.ext
}
userdb {
    driver = static
    args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
}

And here are the postfix parameters I changed from their default settings

myhostname = testcentos.com
mydestination = localhost, localhost.localdomain
mynetworks = 127.0.0.0/8
virtual_alias_domains =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /home/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, permit
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem
smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem
virtual_maildir_extended = yes
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps

inet_interfaces = all
message_size_limit = 30720000
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
virtual_create_maildirsize = yes
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
0

check your /etc/postfix/master.cf file, should contain something like:

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}

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.