Postfix: Virtual Mailbox Mapping and Dovecot

dovecotpostfix

on my server, I would like Postfix to be MTA, to accept mails and to apply a virtual-mailbox-mapping like this (of course with my domain instead of example.org):

in /etc/postfix/main.cf:
virtual_mailbox_maps = hash:/etc/postfix/virtual

/etc/postfix/virtual:
test@example.org mymailbox/

Then the Mail shall be "delivered" by Dovecot (as MDA) to a user directory in /var/mail/vhosts/username.
I therefore configured Postfix and Dovecot like in the Dovecot-Wiki: http://wiki2.dovecot.org/LDA and added as explained the following to the /etc/postfix/master.cf:

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

The problem I have is, that Postfix seems to validate incoming emails over the virtual mapping (test@example.com is delivered, anothername@example.com not), but Postfix does not send the mapping result ("mymailbbox") to deliver, but the original adress ("test@example.org").
My first idea was, that there is another variable, that I could use in master.cf instead of ${recipient} (you can look them up via "man pipe"), but I did not find any which seems to do what I want.

So my Question: Is it possible to use the virtual mapping in Postfix AND the delivery by Dovecot together? If not, is there a possibilty to do something like a virtual mailbox mapping in Dovecot as easy as in Postfix?

Thanks in Advance!

Best Answer

Try setting up your dovecot LDA with the following parameters:

argv=/usr/libexec/dovecot/deliver -f ${sender}
           -d ${user}@${nexthop} -a ${recipient} -n -m ${extension}

I use this to support extensions in the local part (like test+xyz@example.com). You may want to try ${mailbox} in place of ${user}@${nexthop}. Have a look at man 8 pipe for all possible substitutions.

BTW: This is used by me for a working virtual mapping which maps email adresses for multiple domains into virtual mailboxes. On dovecot's side I'm using the same tables (via dovecot's SQL configuration) to do authentication for each virtual mail user. Not sure if you can map virtual mail addresses to real system users this way.