1. 13
  1. 15

    I used to use a similar approach for filtering my mail until I discovered the Sieve filter language. I use it under Dovecot and the filters I’ve written are executed against every incoming mail. There’s no period where you’ll see unfiltered mail like cron or client based tools.

    It’s installed similar to OP’s config - just .dovecot.sieve in your homedir.

    1. 4

      Surprised this isn’t getting upvoted, TBH. I saw the headline and thought, “Why would I use this instead of sieve?”

    2. 5

      Did you know that any standard-compliant email service allows users to have a near-infinite number of email addresses?

      Which standard would that be? The ‘+’ symbol is valid in the local part of an address as per the classic email RFCs. But the notion of “plus addressing” is only a de-facto standard feature that a lot of mail providers accept. It’s not codified in a standard as far as I know. And so there’s no guarantee that user+foo@example and user+bar@example are both valid nor reach the same person.

      1. 5

        Similarly, a “standard-compliant” implementation will treat johnsmith and john.smith as specifying two different mailboxes, but GMail has popularized “dots don’t matter”. And a compliant implementation will treat johnsmith and JohnSmith as specifying different mailboxes, but most mail hosts treat the local-part as case-insensitive (despite the standards saying that only the special mailbox postmaster gets case-insensitive treatment).

        And on and on. So many of the things people get indignant about, and start demanding “compliant” implementations for, are behaviors that aren’t in the RFCs.

        1. 3

          a compliant implementation will treat johnsmith and JohnSmith as specifying different mailboxes, but most mail hosts treat the local-part as case-insensitive (despite the standards saying that only the special mailbox postmaster gets case-insensitive treatment).

          According to RFC2821, the definition of a Mailbox is:

          Mailbox = Local-part “@” Domain
          Local-part = Dot-string / Quoted-string
          ; MAY be case-sensitive

          The definition of MAY is defined elsewhere:

          This word, or the adjective “OPTIONAL”, mean that an item is
          truly optional. One vendor may choose to include the item because
          a particular marketplace requires it or because the vendor feels
          that it enhances the product while another vendor may omit the
          same item.

          So, unless this has been superseded it appears that mailboxes don’t need to be case-sensitive.

          Edit: RFC2821 was in fact superseded by RFC5321, but it did not make case-sensitivity a requirement.

          1. 2

            RFC822:

            Note: This reserved local-part must be matched without sensitivity to alphabetic case, so that “POSTMASTER”, “postmaster”, and even “poStmASteR” is to be accepted.

            Shifting all local-parts to “MAY” be case-sensitive in later RFCs doesn’t undo the original damage, since now you have to play games with which set of RFCs the “compliant” implementation complies with.

        2. 1

          I may be mistaken, then. I will dig that issue and edit my post accordingly if I cannot find the relevant RFC or something. Thanks for the comment, and sorry for the possible mistake!

        3. 2

          I’m going to have to start using this

          1. 2

            Declarative email filtering can be done with procmail. In what way is this better or a different use case?

            1. 2

              I can think of at least two reasons:

              1. a (in my opinion) saner syntax
              2. doesn’t have to run on the mail server
              1. 2

                I didn’t know about procmail. It seems to me that the main difference is that imapfilter is like procmail, but with the capability to do its work over IMAP.

                1. 1

                  Procmail still exists as a package on most systems, but the source project is not really maintained anymore.

                2. 2

                  Well, this sorts my own mail box at work. :)

                  There is no sieve support yet there.

                  It makes a good use of lua features (regarding operators)!