How can I combine Popfile (SMTP) with custom email processing rules on Dovecot?

0

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?

Jannik Jochem

Posted 2013-01-22T20:35:54.093

Reputation: 285

Answers

1

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 {} \;

Alex P.

Posted 2013-01-22T20:35:54.093

Reputation: 2 592

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 – 2013-01-25T12:20:46.120

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. – 2013-01-25T18:04:01.493

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 – 2013-01-25T21:04:01.963

1Since 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. – 2013-01-25T21:48:21.980

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 – 2013-01-25T22:09:24.453

0

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.

Trapper

Posted 2013-01-22T20:35:54.093

Reputation: 29

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 – 2016-02-22T09:33:13.233