Understanding dovecot_virtual_delivery in Dovecot
What is dovecot_virtual_delivery?
If you are facing mail delivery issues related to Dovecot's virtual user system, the problem may be with:
For the Postfix-side of the same delivery flow, see Understanding dovecot_virtual_delivery in Dovecot Mail Server (the Postfix angle). For broader mail-stack debugging, "EHLO not accepted from server!" and Fixing t_dkim_invalid (DKIM Signature Issue).
- Dovecot LDA (Local Delivery Agent) ? Handles local mail delivery to mailboxes
- Dovecot LMTP (Local Mail Transfer Protocol) ? Modern protocol for efficient virtual mail delivery
- Virtual Mailbox Configuration ? Incorrect paths or database settings
- Incorrect Permissions on Mail Directories ? Dovecot can't write to mail storage
Check Dovecot Mail Delivery Method
Dovecot delivers emails in two common ways:
- LDA (Local Delivery Agent) > Used when Dovecot handles local mail delivery directly.
- LMTP (Local Mail Transfer Protocol) > Used for virtual mail users and integrates better with Postfix; more efficient for high-volume mail servers.
Check which method your system uses:
sudo dovecot -n | grep -i "mail_delivery\|protocol lda\|protocol lmtp"
If using LDA, you might see:
mail_plugins = sieve
protocol lda {
mail_plugins = $mail_plugins sieve
}
If using LMTP, you might see:
protocol lmtp {
mail_plugins = quota sieve
}
Verify Dovecot Virtual Mailbox Configuration
If your system uses virtual mail users, make sure Dovecot is properly configured.
Check Dovecot Virtual Mail Setup
Edit the main Dovecot configuration file:
sudo nano /etc/dovecot/conf.d/10-mail.conf
Ensure the following settings are correct for a typical Maildir setup:
mail_location = maildir:/var/mail/vhosts/%d/%n
Where:
- %d > Domain name (e.g., example.com)
- %n > Username (e.g., john)
/var/mail/vhosts/example.com/john
If using a MySQL/PostgreSQL backend for user authentication, also check these typically associated settings:
mail_home = /var/mail/vhosts/%d/%n
mail_location = maildir:/var/mail/vhosts/%d/%n/Maildir
Apply changes and restart Dovecot:
sudo systemctl restart dovecot
Check LMTP Configuration
If using Dovecot LMTP (recommended), ensure it's properly configured to communicate with Postfix.
Edit the master configuration file:
sudo nano /etc/dovecot/conf.d/10-master.conf
Look for a section similar to this (location may vary by distribution):
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
mode = 0600
user = postfix
group = postfix
}
}
In Postfix (/etc/postfix/main.cf), ensure mail delivery is delegated to Dovecot's LMTP socket:
mailbox_transport = lmtp:unix:private/dovecot-lmtp
# or for virtual_transport if using virtual domains:
virtual_transport = lmtp:unix:private/dovecot-lmtp
Restart both services:
sudo systemctl restart postfix dovecot
Fix Mail Directory Permissions
The most common virtual delivery failure is incorrect permissions. Dovecot needs to write to the mail storage directory.
1. Ensure the dedicated vmail user exists:
id vmail
If the user doesn't exist, create it:
sudo useradd -r -d /var/mail -m -s /sbin/nologin vmail
2. Set correct ownership on your mail storage directory:
sudo chown -R vmail:vmail /var/mail/vhosts
sudo chmod -R 770 /var/mail/vhosts
3. In Dovecot configuration (/etc/dovecot/conf.d/10-mail.conf), set the user and group:
mail_uid = vmail
mail_gid = vmail
4. Restart Dovecot:
sudo systemctl restart dovecot
Check Mail Logs for Errors
If mail delivery still fails, check system logs for specific error messages.
Check Dovecot service logs:
sudo journalctl -u dovecot --no-pager | tail -n 30
Check general mail logs:
sudo tail -f /var/log/mail.log | grep -i dovecot
# On some systems:
sudo tail -f /var/log/mail.err
Common errors and their meanings:
"Mailbox not found"> Incorrectmail_locationpath or missing directory."Permission denied"> Wrong ownership or permissions on mail directory."Connection refused"> LMTP service not running or wrong socket path."User doesn't exist"> Authentication/user database misconfiguration.
Summary
| Issue | Fix |
|---|---|
| Mail not delivered to virtual users | Check mail_location in /etc/dovecot/conf.d/10-mail.conf |
| LMTP connection errors | Enable and configure LMTP in /etc/dovecot/conf.d/10-master.conf and match Postfix settings |
| Permission issues | Run chown -R vmail:vmail /var/mail/vhosts and set mail_uid/mail_gid |
| Missing virtual mail directory | Create directory structure (e.g., /var/mail/vhosts/example.com/user/Maildir) with correct ownership |
| Need to check logs for errors | Use journalctl -u dovecot or tail -f /var/log/mail.log |
By systematically checking these configuration areas, your Dovecot virtual mail delivery should work correctly!


