Make Postfix talk to Dovecot

In a previous chapter we made sure that Postfix knows which emails it's allowed to receive. Now what to do with the email? It has to be stored to disk. Usually that's done by Postfix itself which comes with a very basic mail delivery agent (MDA) called "virtual" that just saves incoming emails to virtual mailboxes on your hard disk. But as we will use Dovecot (for IMAP and POP3 access) anyway we can use its more featureful "local delivery agent" (also known as "Dovecot LDA"). It even allows you to use rules to run different automatic actions on incoming email. To make Postfix use that agent you will have to add a service to your /etc/postfix/master.cf:

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

(Note: the second line has to be indented by spaces!)

Restart Postfix:

postfix reload

Also make Postfix use that service for virtual delivery by adding these lines to your /etc/postfix/main.cf:

postconf -e virtual_transport=dovecot
postconf -e dovecot_destination_recipient_limit=1

So now Postfix will pass on incoming emails to virtual users to the /usr/lib/dovecot/deliver program.