Is there a way to filter mails in remote IMAP account?

13,185

Solution 1

A quick google throws up IMAPFilter which looks like it does what you want:

  • Searching of messages using many available criteria in the IMAP protocol, such as:
    • Status (recent, unread, etc.) of a message.
    • Size of a message.
    • Age of a message.
    • Matching of a string or a regular expression pattern in the headers or the body of a message.
  • Ability to use logical operators (and/or/not) while searching messages.
  • Different capabilities available to process messages, including:
    • Deleting messages.
    • Moving messages to a mailbox in the same or different servers
    • Copying messages to a mailbox in the same or different servers.
    • Marking messages or changing message flags.
  • Listing of the available and/or subscribed mailboxes, along with support for the IMAP CHILDREN extension.
  • Creating, deleting, renaming, subscribing or unsubscribing mailboxes
  • Internationalisation (I18N) support.
  • Server namespace support using the IMAP NAMESPACE extension.
  • Secure Socket Layer (SSL) or Transport Layer Security (TLS) encrypted imaps (port 993) connections.
  • Encrypted connections using the IMAP STARTTLS extension.
  • User authentication with the Challenge-Response Authentication Mechanism (CRAM), specifically CRAM-MD5.
  • Perl Compatible Regular Expressions (PCRE) support.

Solution 2

As you already mentioned, procmail is the right way to do this, so you could ask your email provider if they support it just in case - doesn't hurt.

Otherwise, maybe the easiest way is to have an email client always open which does the sorting etc. There used to be locking problems with multiple clients accessing the same IMAP mailbox, but I have not seen those in years.

Solution 3

For sheer lightweightness, you could give Sift a try.

Solution 4

Depending on your IMAP server, you could simply use some implementation of sieve. I think the best support for sieve is provided by cyrus.

Solution 5

Yet another way is to use the ruby gem imap-filter.

https://github.com/flajann2/imap-filter/blob/master/README.org

And example of the DSL,

https://github.com/flajann2/imap-filter/blob/master/examples/default.imap

The DSL is Ruby-based, but you don't need to know much Ruby to use it. The author promises to provide more examples in the near future, and is open to feature requests and pull requests.

Share:
13,185

Related videos on Youtube

Admin
Author by

Admin

Updated on September 17, 2022

Comments

  • Admin
    Admin almost 2 years

    Situation: mail server with IMAP only access. Problem: I want to be able to filter mails (put some mails to various folders, mark them as read and so on).

    Most new email clients have this ability, but I want a standalone filtering program, as I need to use various email clients to connect to this server.

    Generally - something like procmail, but working over IMAP.

    The software will be run on Linux or Solaris.

  • Admin
    Admin almost 15 years
    Well - the solution i'm looking for cannot depend in any way on the server. I have to assume the server is just a dumb IMAP, with no support to nothing smart.
  • Joshua K
    Joshua K over 11 years
    i wish i had tried this before imapfilter.
  • reinierpost
    reinierpost over 9 years
    This is not the answer. The filtering must happen on the IMAP server.
  • reinierpost
    reinierpost over 9 years
    This is not the answer. The filtering must happen on the IMAP server, over which you have no control.
  • selurvedu
    selurvedu over 4 years
    This seems to be abandoned and unmaintained, unlike imapfilter. Correct me if I'm wrong.