I'm trying to run some smartsieve rules on a IMAP mailbox, I can certainly do this for mails that are delivered to that mailbox, but for emails that are already in that mailbox, or ones that a moved to it (via thunderbird/outlook) the rules are not processed. Are there any applications / methods of having a rule(s) run on the mailbox ever X secconds / minutes?

link|improve this question

58% accept rate
feedback

1 Answer

By design, sieve processes mail on arrival in the user's mailbox from the outside. There is no built-in way to process folders afterwards.

It would be possible, though, to collect messages from a cyrus folder ("hotfolder"), and re-send them through the regular MTA to a special mailbox ("specialmailbox") which in turn has the sieve rules you need.

For this purpose, you could use something like this, for example, via cron:

#!/bin/sh
for msg in /var/spool/cyrus/mail/hotfolder; do
    sendmail speicalmailbox <$msg && rm $msg
done

The messages in the "hot" folder are removed from the file system without removing them from the cyrus index, this is not optimal. You could use iprune (part of the cyrus distribution, it will delete messages from folders depending on their age) to fix that. Removal from the file system is needed so we do not process each message multiple times.

I Hope this helps.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.