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.

8 comments

flags

Submitted by Anonymous on Thu, 08/20/2009 - 15:11.

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

Submitted by Anonymous on Mon, 09/21/2009 - 03:33.

I really would like to know that, too

Your comment originally

Submitted by Anonymous on Thu, 02/24/2011 - 12:12.

Your comment originally didn't make sense to me because I thought it was referring to the first line.  Now I understand what you mean - the 'flags' on the second line.  This seems like a good idea.  However, I'm pretty sure the author of this tutorial was merely copying and pasting from:

http://wiki.dovecot.org/LDA/Postfix

If you want to be able to do email+tag@domain style addresses (e.g. GMail-like), the link above should get you started on the right path.

Fetchmail users beware

Submitted by Anonymous on Mon, 09/21/2009 - 03:42.

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

postmap: fatal: /etc/postfix/mysql-virtual-alias-maps.cf: bad st

Submitted by Anonymous on Tue, 01/04/2011 - 20:29.

Hi oliver, Hi christoph,

 

first of all many thanks for your excellent work. A couple of days ago i set up another mailserver and it worked very fine.

 

But now I desperately encounter problems with mysql and postmap. Set up the databases as described and testing it I get the following error:

postmap: fatal: /etc/postfix/mysql-virtual-alias-maps.cf: bad string length 0 < 1: dbname =

It seems that postfix can't interprete the dbname argument. I checked already the right spelling and even set up the database again - but unfortunately with no success :-(.

Dovecot does not have any problems to connect to mysql.

Do you have any hint for me?

thank you very much !

stefan

use full path when testing with postmap

Submitted by Anonymous on Tue, 02/01/2011 - 17:41.

postmap -q xxx mysql:/etc/postfix/mysql-virtual-alias-maps.cf instead of postmap -q xxx mysql:mysql-virtual-alias-maps.cf

 

even if you are into /etc/postfix

postfix reload

Submitted by Anonymous on Sun, 02/27/2011 - 15:27.

I ran into a bit of a problem at this point trying to reload postfix just gives me:

postfix/postfix-script: fatal: the Postfix mail system is not running

I tried "postfix start" which didn't report any errors, but doing a postfix reload just after gave me the above error again.

Any suggestions?

I had this

Submitted by Anonymous on Fri, 06/24/2011 - 12:39.

For me the problem seened to be that I still had senmail running on my system (even though the postfix install removed it). Try rebooting.


Also, try telnet localhost 25 to see what answers - it should be postfix;

The contents of this web site is Copyright © 2000-2011 Christoph Haas - Impressum/Imprints -  Donations welcome

Drupal theme by Kiwi Themes.