dovecot_virtual_delivery is a Dovecot LDA (Local Delivery Agent) method used for delivering emails to virtual mailboxes in a Dovecot-based email system. This is commonly used in virtual mail hosting setups, where email accounts are not tied to actual system users.
It is often used when:
/home/username/Maildir/If you're using Postfix + Dovecot, you need to set Dovecot LDA as the mail delivery method.
sudo nano /etc/postfix/main.cf
# Set Dovecot as the delivery agent
mailbox_command = /usr/libexec/dovecot/deliver
# Set virtual transport to use Dovecot
virtual_transport = dovecot
# If using virtual domains
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailboxes.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-aliases.cf
/usr/lib/dovecot/deliver/usr/libexec/dovecot/deliverfind /usr -name "deliver" 2>/dev/null | grep dovecotsudo nano /etc/postfix/master.cf
Add this configuration at the end of the file:
# Dovecot LDA service definition
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}
# Alternative with more options:
# dovecot unix - n n - - pipe
# flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/dovecot-lda -f ${sender} -d ${recipient} -e
flags=DRhu: D=append Return-Path, R=prepend Delivered-To, h=fold $recipient, u=fold $senderuser=vmail:vmail: Run as vmail user and group-f ${sender}: Specify sender address-d ${recipient}: Specify recipient address-e: Reject on error (alternative option)sudo systemctl restart postfix
# Verify Postfix status
sudo systemctl status postfix
sudo postfix status
sudo nano /etc/dovecot/dovecot.conf
# Or on many systems, the main config is in:
sudo nano /etc/dovecot/conf.d/10-mail.conf
# Set the mail storage location (Maildir format recommended)
mail_location = maildir:/var/mail/vhosts/%d/%n
# Alternative: mdbox format (more efficient for large mailboxes)
# mail_location = mdbox:/var/mail/vhosts/%d/%n
# With indexes
# mail_location = maildir:~/Maildir:INDEX=~/Maildir/indexes
%d = domain name (e.g., example.com)%n = username (e.g., john)%u = full user (e.g., john@example.com)/var/mail/vhosts/example.com/john/# In /etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain login
# Enable SQL authentication
#!include auth-sql.conf.ext
# Or in /etc/dovecot/conf.d/auth-sql.conf.ext
passdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
}
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf.ext
}
# Create base directory
sudo mkdir -p /var/mail/vhosts
# Set ownership to vmail user (create user if needed)
sudo groupadd -g 5000 vmail
sudo useradd -g vmail -u 5000 vmail -d /var/mail -s /bin/false
# Set permissions
sudo chown -R vmail:vmail /var/mail/vhosts
sudo chmod -R 770 /var/mail/vhosts
# For security, consider:
sudo chmod 750 /var/mail/vhosts
sudo systemctl restart dovecot
# Verify Dovecot is running
sudo systemctl status dovecot
sudo doveadm log errors
# Ubuntu/Debian
sudo tail -f /var/log/mail.log
# CentOS/RHEL/Fedora
sudo tail -f /var/log/maillog
# Check specifically for Dovecot errors
sudo grep -i dovecot /var/log/mail.log | tail -20
sudo grep -i "delivery failed" /var/log/mail.log
# Check Dovecot status
sudo systemctl status dovecot
# Check Postfix status
sudo systemctl status postfix
# Check if Dovecot is listening
sudo netstat -tlnp | grep dovecot
sudo ss -tlnp | grep dovecot
# Method 1: Using mail command
echo "Test email body" | mail -s "Test Subject" user@yourdomain.com
# Method 2: Using sendmail
echo "Subject: Test Email" | sendmail -v user@yourdomain.com
# Method 3: Using swaks (if installed)
swaks --to user@yourdomain.com --from test@example.com --server localhost
# Check if mail was delivered
sudo ls -la /var/mail/vhosts/yourdomain.com/user/
# Check Maildir structure
sudo ls -la /var/mail/vhosts/yourdomain.com/user/Maildir/
# Test Dovecot delivery directly
sudo -u vmail /usr/libexec/dovecot/deliver -d user@yourdomain.com <
| Step | Action | Configuration File |
|---|---|---|
| Enable virtual delivery in Postfix | Add virtual_transport = dovecot |
/etc/postfix/main.cf |
| Configure Postfix to use Dovecot LDA | Add dovecot service definition | /etc/postfix/master.cf |
| Set mail location in Dovecot | mail_location = maildir:/var/mail/vhosts/%d/%n |
/etc/dovecot/dovecot.conf or /etc/dovecot/conf.d/10-mail.conf |
| Configure authentication | Set up SQL or passwd authentication | /etc/dovecot/conf.d/10-auth.conf |
| Fix permissions | chown -R vmail:vmail /var/mail/vhosts |
Filesystem |
| Restart services | systemctl restart postfix dovecot |
Systemd |
| Check logs for errors | tail -f /var/log/mail.log |
Log files |
| Test delivery | echo "Test" | mail -s "Test" user@domain.com |
Command line |
Properly configured dovecot_virtual_delivery enables efficient, secure mail delivery for virtual hosting environments where system users don't correspond to email users!