Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I host my own mail server using Postfix and Dovecot on a virtual ubuntu server. In order to keep on top of my inbox, I use Popfile on the server to sort emails into categorized folders in my IMAP mailbox.

Now I want to forward all email that Popfile puts into that specific folder to somebody else. As far as I unterstand it, a filtering framework such as Sieve evaluates the processing rules only on delivery.

Is it possible to somehow make the server watch a folder for emails to refilter? Or is there another elegant approach to solve my problem that I have not considered yet?

share|improve this question
up vote 1 down vote accepted

While it is possible to do this unnatural thing you are asking for (i.e. rerunning dovecot local delivery on messages in a Maildir folder to force reprocessing of those messages by Sieve), the "elegant approach" would be getting rid of Popfile altogether and replacing it with spamassassin for spam detection and Sieve scripts for the rest of your sorting rules.

If you insist on redelivering a message the command is:

/usr/lib/dovecot/deliver -d <mailbox_name> -p <path_to_the_message_file>

to redeliver all messages in IMAP folder "Filtered" of user "john":

find /home/john/Maildir/.Filtered/cur/ -type f -exec /usr/lib/dovecot/deliver -d john -p {} \;
share|improve this answer
I am aware of this possibility. However, I use Popfile because it can categorize my non-spam email using bayesian filtering. This is its killer feature and the reason why I use it over spamassassin or some other spam-specific filtering solution. Correct me if I'm wrong, but as far as I know spamassassin cannot do this type of categorization at all. – Jannik Jochem Jan 25 '13 at 12:20
Can you give an example of such non-spam message and how you would like it to be sorted? From my experience most non-spam correspondence has enough legitimate information like sender's address, etc. not to have to resort to using Bayes for filtering. – Alex P. Jan 25 '13 at 18:04
For example, I have a folder for all kinds of newsletters that are sent by different organizations. If I was going to use filtering rules for this, I'd have to spell out the sender address / domain for each of these organizations. I have a "work" folder for work-related stuff for which the same goes. Then I have another folder for personal correspondence. How would you go about defining a rule for that? – Jannik Jochem Jan 25 '13 at 21:04
Since you are hosting your own mail server I am assuming you have your own domain name. In this case you should use different mailboxes for different purposes. You can set them up as aliases and still have just one physical mailbox for convenience. Then you would be able to use "X-Original-To" header for filtering. Also do not be afraid of having to create the rules for your existing subscriptions. It is easy to automate. Parse the messages you have already sorted - save all unique sender addresses in "work" folder to a file and then use it as a lookup table for the "work" filter rule. – Alex P. Jan 25 '13 at 21:48
Well this all ends up costing lots of time to set up, while the Popfile approach works pretty nicely for me right now. Thank you for your suggestions, I think I will give them a try sometime. This makes sense since Popfile does not seem to get a lot of updates as of late. However, this does not solve the task I am trying to accomplish right now. – Jannik Jochem Jan 25 '13 at 22:09

This thread is so old but I do have something to pass on to Jannik. Popfile does not direct any email to any folders. All it does is put a classification tag in the email. Something else directs the mail to a folder. Whatever you are using to filter on that popfile tag should be instructed to do the forwarding of the mail elsewhere rather than to the folder the mail is presently being directed to.

share|improve this answer
Actually, this is only correct when using Popfile in POP3 mode. If you're using IMAP, Popfile will put the mails in the designated folders. – Jannik Jochem Feb 22 at 9:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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