Era Host hosting
EraHost – Free Domain, Cheap Hosting!
Client Area
Support 24/7
Menu

Understanding dovecot_virtual_delivery in Dovecot Mail Server

5 min read
15.11.2025

What is dovecot_virtual_delivery?

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.

dovecot_virtual_delivery Dovecot Mail Server
dovecot_virtual_delivery — Postfix→Dovecot mailbox delivery (LMTP).

For closely related Exim/Dovecot/mail-stack topics, see "EHLO not accepted from server!", Error 421 — Too Many Connections, and Fixing t_dkim_invalid (DKIM Signature Issue).

Virtual Mail System Architecture: In a traditional Unix mail system, each user has a system account. In a virtual mail system (like web hosting), email users are defined in a database (MySQL, PostgreSQL) and mail is delivered to virtual mailboxes without corresponding system accounts.

It is often used when:

  • You are using Postfix + Dovecot as a mail system
  • Emails are stored in virtual mailboxes rather than /home/username/Maildir/
  • Mail is handled via a MySQL or PostgreSQL database backend rather than system users
  • You're running a web hosting server with multiple domains and users

1. How to Enable dovecot_virtual_delivery in Postfix

If you're using Postfix + Dovecot, you need to set Dovecot LDA as the mail delivery method.

Edit Postfix Main Configuration

Open Postfix Configuration File

sudo nano /etc/postfix/main.cf

Add or Modify These Lines

# 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
Path Variations:
  • Debian/Ubuntu: /usr/lib/dovecot/deliver
  • CentOS/RHEL/Fedora: /usr/libexec/dovecot/deliver
  • Find the correct path: find /usr -name "deliver" 2>/dev/null | grep dovecot
Linux VDS
High performance for your projects
  • Root access and flexible setup
  • Control panel
  • NVMe disks
  • DDR5
Linux VDS

2. Configure Postfix to Use Dovecot LDA

Edit Postfix Master Configuration

Open Postfix Master Configuration File

sudo nano /etc/postfix/master.cf

Add Dovecot Service Definition

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
Parameter Explanation:
  • flags=DRhu: D=append Return-Path, R=prepend Delivered-To, h=fold $recipient, u=fold $sender
  • user=vmail:vmail: Run as vmail user and group
  • -f ${sender}: Specify sender address
  • -d ${recipient}: Specify recipient address
  • -e: Reject on error (alternative option)

Restart Postfix Service

sudo systemctl restart postfix

# Verify Postfix status
sudo systemctl status postfix
sudo postfix status

3. How to Configure Dovecot for Virtual Delivery

Edit Dovecot Configuration

Open Dovecot Configuration File

sudo nano /etc/dovecot/dovecot.conf

# Or on many systems, the main config is in:
sudo nano /etc/dovecot/conf.d/10-mail.conf

Configure Mail Location

# 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
Variable Explanation:
  • %d = domain name (e.g., example.com)
  • %n = username (e.g., john)
  • %u = full user (e.g., john@example.com)
  • Resulting path: /var/mail/vhosts/example.com/john/

Configure Authentication (if using SQL)

# 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
}

Set Correct Permissions

Create Mail Directory Structure

# 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

Restart Dovecot

sudo systemctl restart dovecot

# Verify Dovecot is running
sudo systemctl status dovecot
sudo doveadm log errors

4. Troubleshooting dovecot_virtual_delivery Issues

Check Mail Logs for Errors

Check System Mail Logs

# 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

Ensure Services Are Running

# 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

Test Mail Delivery Manually

Send a Test Email

# 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 Mailbox Structure

# 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 <
Permission Issues: The most common problem is incorrect permissions. Ensure the vmail user owns all mail directories and files. Also check that Postfix can access the Dovecot deliver binary.

5. Summary of dovecot_virtual_delivery Setup

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!

Frequently asked questions
LMTP via Dovecot. procmail is unmaintained; maildrop still works but loses on observability and Sieve support. Dovecot LMTP gives you per-user Sieve filters, quota enforcement, and integrates directly with Dovecot's mailbox format — fewer moving parts, fewer race conditions, and easier scaling.
Postfix queue (`postqueue -p`) and Dovecot LMTP log. If Postfix shows "connect to dovecot-lmtp: Connection refused" — Dovecot's LMTP isn't listening (check `dovecot -a | grep listen`). If Postfix queue is clear and Dovecot logs nothing — Postfix delivered somewhere else (check master.cf for the actual transport). If Dovecot logs "sieve script failed" — buggy Sieve filter.
Dovecot LMTP needs `mail_plugins = $mail_plugins sieve` in `lmtp { }` block (separately from imap block). Many configs enable Sieve only for IMAP and forget LMTP — IMAP-side filtering works (you can see filters in webmail) but delivery doesn't apply them. Reload Dovecot after the change.
Yes — Postfix → Dovecot LMTP scales to thousands of deliveries/second on modern hardware. For very high volume (mailing-list scale), tune `lmtp_destination_concurrency_limit` upward and split delivery across multiple Dovecot instances behind a load balancer or by-domain. The bottleneck is usually disk IO on the mailbox storage, not the LMTP daemon itself.
Related articles
Understanding dovecot_virtual_delivery in Dovecot
mx10.mailspamprotection.com: Understanding and Configuring It
MX Hosting — What It Is and How to Use It? Complete Guide