1

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?

1

Is there an easy(-ish) way to get a similar workflow, having the Server retrieve emails and add them to the local IMAP server?

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 invokes dovecot-lda:

[destination]
type      = MDA_external
path      = /Applications/Server.app/Contents/ServerRoot/usr/libexec/dovecot/dovecot-lda 
arguments = ("-d", "USERNAME")
allow_root_commands = True

Note that allow_root_commands is required because getmail will need to be run as root to invoke dovecot-lda.

Aside: The path for dovecot-lda is specified in the postfix configuration file /Library/Server/Mail/Config/postfix/master.cf:

dovecot   unix  -       n       n       -       25      pipe
  flags=DRhu user=_dovecot:mail argv=/Applications/Server.app/Contents/ServerRoot/usr/libexec/dovecot/dovecot-lda -d ${user}

What about server-side filtering? How can that be setup?

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 with sievec), 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 the mail 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:

mail-info.log:Feb 13 17:14:52 lda(pid 6108 user USERNAME-NOT-GUID): Info: sieve: msgid=<whatever...>: ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .