[Dovecot] Sieve as mail client?

Stephan Bosch stephan at rename-it.nl
Sun Sep 23 20:31:27 EEST 2012


On 9/20/2012 2:11 PM, Tom Horsley wrote:
> A slightly off topic question, but maybe someone here has seen
> something like this:
>
> I want a program that operates entirely on the client side of
> an IMAP server, and implements the sieve filtering language
> by doing the necessary client side operations to move mail
> on the IMAP server, expunge mail, etc.
>
> It would also act as a proxy between my real mail client and
> the IMAP server so I'd never see any mail that hasn't been
> filtered first.
>
> The benefits are obvious: I could finally get sieve filtering
> on my stupid corporate exchange mail server :-).

Interesting idea. I've been experimenting a bit with the sieve-filter 
command line tool and the Dovecot imapc mail storage backend. This does 
not entirely match your proposed solution, since it'll have to operate 
as a cron job, but at least it is a start.

I've configured my experiment as follows:

=> I built a simple dovecot.conf

protocols = none

listen = *, ::

mail_location = imapc:~/imapc
imapc_host = your.host.tld
imapc_port = 143
imapc_user = username
imapc_password = <whatever>
imapc_ssl = starttls
imapc_ssl_verify = no

=> I tested whether IMAP connection works:

stephan at klara:~/test$ /usr/lib/dovecot/imap -c ./dovecot.conf
* PREAUTH [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID 
ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS 
THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN 
NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH 
ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY 
MOVE] Logged in as stephan
2342 SELECT INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] 
Flags permitted.
* 8274 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1348169448] UIDs valid
* OK [UIDNEXT 8275] Predicted next UID
* OK [NOMODSEQ] No permanent modsequences
2342 OK [READ-WRITE] Select completed.

=> I built a Sieve script called test.sieve:

require "fileinto";
require "mailbox";

# Just moves mail elsewhere
fileinto :create "Target";

=> And finally tested operation using sieve-filter:

sieve-filter -v -e -W -c dovecot.conf test.sieve INBOX

In the process a few problems were encountered and solved. This means 
that this little experiment will only work with the latest revisions of 
Dovecot v2.1/v2.2 and a matching Pigeonhole from their respective 
Mercurial repositories.

The conclusion so far is that, in essence, what you'd like to do is 
possible. However, to make Sieve filtering look like it is being run at 
delivery rather than at regular intervals in the background, we will 
need to build some sort of IMAP plugin that monitors INBOX for new 
messages and passes them through a Sieve filter before the user's 
proxied IMAP client can see them. I'll have to investigate how much work 
implementing this would be.

Regards,

Stephan.








More information about the dovecot mailing list