Dovecot LDA with Postfix
========================

This page contains only information specific to using LDA with Postfix, see
<LDA.txt> for more information about using the LDA itself.

System users
------------

If you wish you use 'dovecot-lda' for all system users on a single domain mail
host you can do it by editing 'mailbox_command' parameter in

'/etc/postfix/main.cf' (postconf(5) [http://www.postfix.org/postconf.5.html]):

---%<-------------------------------------------------------------------------
mailbox_command = /usr/local/libexec/dovecot/dovecot-lda
#  or
mailbox_command = /usr/libexec/dovecot/dovecot-lda
#  or
mailbox_command = /usr/lib/dovecot/dovecot-lda
#  or wherever it was installed in your system.
---%<-------------------------------------------------------------------------

Then run 'postfix reload'.

 * Be sure that /var/mail or wherever you deliver mail is writable by the
   dovecot-lda process, which does not run as root.
 * Postfix's 'mailbox_size_limit' setting applies to all files that are written
   via dovecot-lda. The default is 50 MB, so dovecot-lda can't write any files
   larger than that, including mbox files or log files. This shows up only in
   Dovecot's logs:

   ---%<----------------------------------------------------------------------
   dovecot-lda(user): write() failed with mbox file /home/user/mail/foo: File
   too large (process was started with ulimit -f limit)
   ---%<----------------------------------------------------------------------

 * If you have trouble seeing anything in Dovecot's logs, see <LDA#Logging>
   [LDA.txt].

Some detailed config files and examples at
http://heinous.org/wiki/Virtual_Domains%2C_Postfix%2C_Dovecot_LDA%2C_and_LDAP
[http://heinous.org/wiki/Virtual_Domains,_Postfix,_Dovecot_LDA,_and_LDAP]

Virtual users
-------------

Dovecot LDA is very easy to use on large scale installations with Postfix
virtual domains support, just add a 'dovecot' service in
'/etc/postfix/master.cf' (master(5) [http://www.postfix.org/master.5.html]):

---%<-------------------------------------------------------------------------
dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/local/libexec/dovecot/dovecot-lda -f
${sender} -d ${recipient}
---%<-------------------------------------------------------------------------

An example using address extensions (ie user+extension@domain.com (don't forget
to define the proper recipient_delimiter in Postfix's main.cf)) to deliver to
the folder 'extension' in your maildir (If you wish to preserve the case of
${extension}, remove the 'hu'flags [http://www.postfix.org/pipe.8.html], and be
sure to utilize <Modifiers> [Variables.txt] in your dovecot.conf for mail
locations and other configuration parameters that are expecting lower case):

---%<-------------------------------------------------------------------------
dovecot unix    -       n       n       -       -      pipe
  flags=DRhu user=vmail:vmail argv=/usr/local/libexec/dovecot/dovecot-lda -f
${sender} -d ${user}@${nexthop} -m ${extension}

# or with v1.1.2+ if you have a INBOX/ namespace prefix:
dovecot unix    -       n       n       -       -      pipe
  flags=DRhu user=vmail:vmail argv=/usr/local/libexec/dovecot/dovecot-lda -f
${sender} -d ${user}@${nexthop} -m INBOX/${extension}
---%<-------------------------------------------------------------------------

This example ignores address extensions (ie user+extension@domain.com delivers
just like user@domain.com):

---%<-------------------------------------------------------------------------
dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/dovecot-lda -f ${sender} -d
${user}@${nexthop}
---%<-------------------------------------------------------------------------

Replace 'vmail' above with your virtual mail user account.

Then set 'virtual_transport' to 'dovecot' in '/etc/postfix/main.cf':

---%<-------------------------------------------------------------------------
dovecot_destination_recipient_limit = 1
virtual_mailbox_domains = your.domain.here
virtual_transport = dovecot
---%<-------------------------------------------------------------------------

And remember to run

---%<-------------------------------------------------------------------------
postfix reload
---%<-------------------------------------------------------------------------

Virtual users with multiple uids/gids
-------------------------------------

If you need multiple uids/gids you'll need to set dovecot-lda setuid root or
invoke it through sudo. See <LDA#multipleuids> [LDA.txt] for how to do this
securely.

Postfix with a NFS mail store
-----------------------------

If you are experiencing problems with dovecot-lda processes hanging when
delivering to a NFS mail store, it's likely that the dovecot-lda process is
hanging while waiting for free locks.  The occurrence of this can be greatly
reduced, if not eradicated, by forcing Postfix to only deliver to the same
recipient one at a time.

---%<-------------------------------------------------------------------------
dovecot_destination_concurrency_limit = 1
---%<-------------------------------------------------------------------------

(This file was created from the wiki on 2010-07-02 21:30)
