I have a Mac mini Server with OS X Mavericks 10.9.1 and Server.app v3.0 installed. IMAP (dovecot) is running and accessible from Mail clients.
What I want is to have the server fetch emails from my various email accounts and "dump" them into the IMAP server.
I was previously able to do this on Linux by using getmail to fetch the emails, which would send the emails through procmail
, which would deliver them directly into the Maildir folder which dovecot
read.
Unfortunately the above process won't work with Server.app v3.0, as apparently the /Library/Server/Mail/Data/mail/*
directories must be owned by _dovecot
, which means Joe Random User can't write to them, which rules out procmail/etc.
Is there an easy(-ish) way to get a similar workflow, having the Server retrieve emails and add them to the local IMAP server?
What about server-side filtering? How can that be setup?
Best Answer
The key is to use the
dovecot-lda
program (lda for Local Deliver Agent), which can write messages into the IMAP server.For example, if using
getmail
, you could provide a[destination]
section which invokesdovecot-lda
:Note that
allow_root_commands
is required becausegetmail
will need to be run as root to invokedovecot-lda
.Aside: The path for
dovecot-lda
is specified in the postfix configuration file/Library/Server/Mail/Config/postfix/master.cf
:Dovecot is configured to use Sieve (
/Library/Server/Mail/Config/dovecot/conf.d/90-sieve.conf
). Sieve rules are stored in/Library/Server/Mail/Data/rules/%u/dovecot.sieve
(see/Library/Server/Mail/Config/dovecot/conf.d/90-sieve.conf
), which unfortunately isn't easily writeable.To install additional Sieve rules, use a Sieve editor, e.g. Sieve clients. Note that you need to use the correct port (Server.app defaults to port 4190; see
/Library/Server/Mail/Config/dovecot/conf.d/20-managesieve.conf
).Unfortunately, after spending far too much time trying to make this work, I've given up on using a Sieve client.
If you're root, create a
.sieve
file (verify syntax withsievec
), then copy to/Library/Server/Mail/Data/rules/%u/dovecot.sieve
. Note:%u
is the user's GUID, not their user name (i.e./Library/Server/Mail/Data/mail/%u
should exist), and/Library/Server/Mail/Data/rules/%u
should have permissions 775 (writable by themail
user).If you're not root...get root and see above.
When the Sieve rules are in place,
/Library/Logs/Mail/mail-info.log
will contain a line similar to: