Make Postfix send mails to Dovecot

In the 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 you can use to save 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"). 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 -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 far this will make Postfix pass on incoming emails to virtual users to the /usr/lib/dovecot/deliver program. Now it is time to configure Dovecot in the next chapter.

Comments

flags

is there a reason, why not set the flag O for the X-Original-To Header ?

<Zitat>

O

Prepend an "X-Original-To: recipient" message header with the recipient address as given to Postfix. Note: for this to work, the transport_destination_recipient_limit must be 1.

</Zitat>

I really would like to know

I really would like to know that, too

Fetchmail users beware

Hi,

after upgrading to lenny I experienced an error __only__ to mails fetched with fetchmail.

Sep 21 03:36:10 smtp postfix/pipe[13083]: A1AA5FAD3: to=<abcd@abcd.de>, relay=dovecot, delay=0.11, delays=0.09/0/0/0.02, dsn=5.4.6, status=bounced (mail forwarding loop for abcd@abcd.de)

After googleing a bit I found the solution. It seems postfix now makes loop detections on pipes. So fetchmail adds an 'delivered-to' header to the mail and postfix/dovecot detects this when wanting to add its own same address. Oh, please excuse if I understood the reason wrong

Anyway, the solution might be interesting for others too, just add in the fetchmailrc at the fetching lines the keyword 'dropdelivered' and everything will be fine again.

Source: http://www.kolab.org/pipermail/kolab-users/2005-November/003895.html