Dovecot deliver and sieve
I read mail from several addresses using mail clients on a few machines. I wanted to aggregate all the mail in one IMAP account to allow me the greatest flexibility when reading mail. I had set up postfix and dovecot on my Linode (running Ubuntu Intrepid), and also used getmail to fetch mail from some POP accounts. This was working for me to a certain extent, but it was falling down when I was using the mail client (Evolution) to filter messages into different folders: I got too many duplicate messages when I switched machines.
What I wanted to do was filter the mail on the server side. Getmail can pass messages to an external mail delivery agent (MDA) for delivery. Since I was using dovercot, its local delivery agent (LDA) deliver seemed the best option. I could then use dovecot’s sieve plugin to do the filtering. Unfortunately, I couldn’t get it working, but after persevering I manage to succeed.
First, configure getmail. Use the destination section to set the external MDA:
[destination] type = MDA_external path = /usr/lib/dovecot/deliver
That seemed simple enough. Where I went wrong was not realising that deliver needed some configuring too. deliver gets configured in the protocol lda section of dovecot.conf. Make sure that the postmaster_address is set to something; if not, a fatal error is thrown. I spent some time thinking that the root problem wasn’t that there was no postmaster_address, but that deliver was faulting elsewhere and then complaining that there was no postmaster_address. I repeat, you must set postmaster_address.
For filtering, enable the sieve plugin. On Ubuntu (Intrepid), the CMUsieve plugin is provided, so include “cmusieve” in your list of mail plugins
# Space-separated list of plugins to load mail_plugins = cmusieve
To check what deliver has done, if you haven’t found the mail in your store as expected, look in the /var/log/mail.log and mail.err to see what’s happened. Maybe check where dovecot is configured to log.
And, to check that the filter is working, the sieve plugin will write out errors to .dovecot.sieve.err. Check for this file if you think the filter is failing.
