Subject: postfix mail filtering

From: Tony van der Hoff <[email-masked]>
Date: Wed, 31 Aug 2016 13:21:13 +0100

Hi list,

I'm running postfix under Wheezy on my VPS, using a more or less 
out-of-the-box configuration. My users access their mail via IMAP.

I subscribe to a number of mail lists, such as this one. I currently use 
Thunderbird's filtering capability to sort mail into a number of 
subdirectories within my inbox, which works fine, but requires me to set 
up all my workstayions (laptop, home, work) with the same filters. I 
have now acquired an Android smartphone, which has no filtering 
capability. In any case, keeping a number of workstations in sync is a pain.

So, I'd like to perform the filtering on the server (for my user 
initially, then perhaps for others). My extensive googling reveals that 
there are many tutorials for filtering spam, but that's not really my 
problem.

I can't find any tutorials on how to set up filters based on, say 
subject:, from:, or to: fields, but feel certain such must exist.
Can any kind person direct me to a suitable tutorial, please?

Thanks, Tony
-- 
Tony van der Hoff        | mailto:[email-masked]
Buckinghamshire, England |

---

From: Dan Ritter <[email-masked]>
Date: Wed, 31 Aug 2016 10:02:19 -0400

On Wed, Aug 31, 2016 at 01:21:13PM +0100, Tony van der Hoff wrote:
> subdirectories within my inbox, which works fine, but requires me to set up
> all my workstayions (laptop, home, work) with the same filters. I have now
> acquired an Android smartphone, which has no filtering capability. In any
> case, keeping a number of workstations in sync is a pain.
> 
> So, I'd like to perform the filtering on the server (for my user initially,
> then perhaps for others). My extensive googling reveals that there are many
> tutorials for filtering spam, but that's not really my problem.
> 
> I can't find any tutorials on how to set up filters based on, say subject:,
> from:, or to: fields, but feel certain such must exist.

You can use:

- sieve, a language for controlling filtering on IMAP servers.
  Supported by Thunderbird but not very much else.

- procmail, a language for filtering on delivery (postfix will
  call it) -- widely known, but arcane syntax and requires shell 
  access to edit or place the ~/.procmailrc

- maildrop, aka mailfilter, a language for filtering on delivery
  (postfix will call it, too) -- less widely known, but has
  syntax that is much more readable than procmail. Requires
  shell access to place a ~/.mailfilter file.

All of these have Debian packages.

-dsr-

---

From: Tony van der Hoff <[email-masked]>
Date: Thu, 1 Sep 2016 17:52:41 +0100

> All of these have Debian packages.

Thanks for the heads-up, Dan. I'll take a look at maildrop.

---

From: "Perry E. Metzger" <[email-masked]>
Date: Wed, 31 Aug 2016 08:33:52 -0400

On Wed, 31 Aug 2016 13:21:13 +0100 Tony van der Hoff
<[email-masked]> wrote:
> initially, then perhaps for others). My extensive googling reveals
> that there are many tutorials for filtering spam, but that's not
> really my problem.

What you're looking for is an implementation of the Sieve
language/system for mail filtering. You don't say what IMAP
server you are using, but Dovecot has an implementation of this called
"Pigeonhole" that is very likely what you want.

Perry
-- 
Perry E. Metzger		[email-masked]

---

From: Tony van der Hoff <[email-masked]>
Date: Thu, 1 Sep 2016 17:51:10 +0100

> "Pigeonhole" that is very likely what you want.
Thanks, Perry, I'm actually using Courier, and Google tells me there is 
no Sieve plugin for it. I shudder at reconfiguring the system for Dovecot!

Thanks for giving me another keyword (sieve) to search!

---

From: Joe <[email-masked]>
Date: Thu, 1 Sep 2016 18:42:14 +0100

On Thu, 1 Sep 2016 17:51:10 +0100
Tony van der Hoff <[email-masked]> wrote:

> > server you are using, but Dovecot has an implementation of this
> > called "Pigeonhole" that is very likely what you want.
> >
> > Perry
> >  
> Thanks, Perry, I'm actually using Courier, and Google tells me there
> is no Sieve plugin for it. I shudder at reconfiguring the system for
> Dovecot!
> 

I don't know anything about Postfix, but I'd have thought that the job
of dropping sorted mail into different Maildir directories was one of
its tasks.

Certainly exim4 sorts the mail for me into mail directories used by
Courier, on the basis of a .forward file, and exim4 also implements
Sieve if I ever need real complication.

-- 
Joe