Email filters

Sort, file, flag, redirect or block mail as it arrives, at three levels: the whole server, one domain, or one mailbox. Reqad writes standard Sieve, so the per-mailbox rules are the same ones the user sees in webmail.

The three levels

Filters run in this order, and every level that matches gets its say:

  • Server-wide — applies to every mailbox on the server. Good for blocking a sender everywhere, or flagging what SpamAssassin marked.
  • Per domain — applies to every mailbox in one domain.
  • Per mailbox — the mailbox owner's own rules, and the only level they can edit themselves.

Open Email → Email Filters and pick a level. Per domain and per mailbox show every domain or mailbox that has rules; choose one from the list to add a rule to it.

An admin rule can end the chain. A server-wide or per-domain rule that files, redirects, rejects or discards a message stops everything below it - including the mailbox owner's own filters. Leave “Stop all further filtering” unticked and Reqad keeps the chain alive automatically; tick it when you really do want the rule to be the last word. Because the message is then also delivered normally, filing it at the admin level can leave a second copy.

Building a rule

A rule is some conditions and some actions. Conditions test From, Subject, To, Any Recipient (To or Cc), Cc, Reply, Body, Message size, List ID or the spam headers, with operators like contains, is, begins with, matches regex and their negations. Set Match to decide whether all conditions must hold or any one of them. A rule with no conditions matches every message.

Actions:

  • File into folder - the folder is created if it does not exist. Use Parent/Child for a subfolder.
  • Redirect to address, Reject with message, Discard (silently, with no bounce) and Keep in Inbox.
  • Add / Set / Remove flags - Read, Answered, Flagged, Deleted or Draft. Set replaces every flag on the message; Add leaves the others alone.
  • Pipe to a program - server-wide and per-domain only, see below.

On the admin levels a rule also has a priority (lower runs first; new rules start at 10, leaving room to slot one in ahead) and can be disabled without deleting it.

Webmail and mail clients

Per-mailbox filters live in the mailbox itself, as a Sieve script. Reqad and Roundcube edit the same script: a rule created in the panel appears under Settings → Filters in webmail, and an edit made there shows up in the panel. Reqad re-reads the script before every save, so the two cannot overwrite each other silently.

If a script was written by hand, or uses Sieve features the rule editor does not model, Reqad shows the raw source for editing instead of rewriting it and risking what it does.

ManageSieve listens on the server's loopback interface only, so webmail and the panel can reach it but external mail clients such as Thunderbird cannot manage filters remotely.

Autoresponders are separate

Out-of-office replies are not filters - manage them under Email → Autoresponders, where they get start and end dates. Do not add a vacation rule in webmail as well, or the mailbox will reply twice.

Pipe to a program

A server-wide or per-domain rule can pipe a message to a program - a ticket system, an archiver, a parser. For safety a filter can only name a program that an administrator has already installed in /var/lib/reqad/sieve/bin; it can never name an arbitrary path or command line. Drop an executable there as root and it appears in the action's list.

The program receives the whole message on standard input and runs as the mailbox's own system user. Piping counts as delivering the message, so add a Keep in Inbox action too if you also want a copy in the mailbox.

This action is not offered on the per-mailbox level: running programs on the server is an administrator's decision, not a mailbox owner's.

Spam

SpamAssassin scores mail before filters run, so the simplest spam rule is a server-wide filter on Spam Flag (X-Spam-Flag) containing YES, filing into a Spam folder. Use Spam Score or Spam Status if you want to act on the score rather than the yes/no verdict.

Prefer filing spam over discarding it. A discard is silent and unrecoverable - if the rule is ever wrong, nobody finds out.

Moving filters from cPanel

cPanel writes its filters in Exim filter syntax at all three levels. The Transfer wizard can pull them across and convert them to Sieve. Anything it cannot convert with confidence is listed with the original text rather than half-translated, so you can recreate it by hand.


Need a hand? Register for early access or contact us.