LochStudios  /  Help Centre  /  cPanel  /  Create Email Filters (Mailbox Rules)

Create Email Filters (Mailbox Rules)

Create server-side rules in cPanel that file, discard, or redirect incoming mail for a shared-hosting address.

Updated

Email filters are rules that run on the server when a message arrives. They can file mail into a folder, send a copy to another address, or discard it, before you open Webmail or a mail app. They apply to that mailbox whether you read it in Roundcube, Outlook, or on a phone.

This article is for addresses on shared hosting (cPanel). If you have LochStudios Mail (hosted business email), create rules in WebMail instead. See Create Filters and Rules in Axigen Webmail.

Need the address first? Create an email account.

Open cPanel from the portal. Do not guess a hostname.

Open Email Filters

  1. Sign in at the portal.
  2. Open the hosting service for the domain.
  3. Click Log in to cPanel.
  4. In the Email section, open Email Filters.
  5. Find the address and click Manage Filters.

Use Email Filters for one mailbox. Use Global Email Filters in the same Email section only when the same rule should apply to every address on this hosting account.

Create a folder first (if you will file mail)

Deliver to Folder only works if the folder already exists.

  1. From Email Accounts, click Check Email on that address and choose Roundcube.
  2. Create the folder in the left sidebar (or under Settings, then Folders).
  3. Return to Email Filters and Manage Filters.

The folder then appears in the filter action list. IMAP clients see the same folder.

Create the filter

  1. On the Manage Filters screen, click Create a New Filter.
  2. Filter Name: something you will recognise later, for example Newsletters or Invoices.
  3. Under Rules, set what the message must match.
  4. Click + to add another rule if you need more than one. Choose and (every rule must match) or or (any rule can match).
  5. Under Actions, choose what happens.
  6. Click + if the same match should do more than one thing (for example deliver to a folder and stop processing).
  7. Click Create.

New incoming mail is checked against the rule from this point on. Existing messages already in the inbox are not moved.

Rules you can match

RuleWhat it looks at
FromThe sender address
ToThe address on the To line
SubjectWords in the subject
BodyText in the message body
ReplyThe Reply-To address
Any HeaderAny message header
Any recipientTo, Cc, or other recipient fields
List IDMailing-list mail

Common operators:

  • contains / does not contain
  • equals
  • begins with / ends with
  • does not begin / does not end

Start with contains unless you need an exact address. Be specific so the rule does not catch mail you still want in the inbox.

If cPanel Spam Filters is on for the account, you can also match Spam Status, Spam Bar, or Spam Score. Use those to file obvious junk. Do not discard on a loose keyword.

Actions

ActionResult
Deliver to FolderFile the message in a folder you already created
Redirect to EmailSend a copy to another address
Discard MessageDrop the message. The sender is not told. Use only on a tight match.
Stop Processing RulesDo not run later filters on this message
Fail With MessageSend the mail back to the sender with a short note you write

You can add more than one action. A common pair is Deliver to Folder, then Stop Processing Rules.

Leave Pipe to a Program alone unless we have asked you to use a script. If you need a custom handler, open a support ticket.

Redirect is not the same as a forwarder. A forwarder sends all mail for an address. A filter sends only the messages that match.

Filters do not send a reply. For out-of-office text, use an autoresponder.

Examples

PurposeRuleAction
File a newsletterFrom contains news@example.comDeliver to Folder Newsletters
File invoicesFrom contains billing@ or Subject contains InvoiceDeliver to Folder Invoices
Copy urgent mailSubject contains URGENTRedirect to Email, and Deliver to Folder Important
Drop a known junk phraseSubject contains a phrase you never wantDiscard Message (keep this tight)

After you save a rule, send yourself a test message that should match, then check the folder (or the other address) in Roundcube.

cPanel also has Test Filter on the Manage Filters screen. Paste a full raw message and run the test to see which rule would fire.

Manage existing filters

Still under Manage Filters for that address:

  • Edit changes the name, rules, or actions.
  • Delete removes the rule. Incoming mail then follows the remaining filters, or lands in the inbox.
  • Filters run in the order they appear. Put the most specific rules first, and use Stop Processing Rules when a match should be the last word.

There is no off switch. Delete the rule to stop it, and create it again when you need it.

Tips

  • Create the destination folder in Roundcube before you choose Deliver to Folder.
  • Prefer filing over discard until you are sure the match is safe.
  • Review old filters after you change addresses or senders.
  • Filters only apply to new incoming mail. Move older messages by hand in Roundcube.
  • Mail still has to arrive at this hosting account. If MX for the domain points somewhere else, these rules never see the message.

If a filter misbehaves

  • Nothing moves: confirm you edited Email Filters for the same address the mail is delivered to. Check spelling, spaces, and whether you used contains when you meant equals.
  • Too much mail vanished: open Trash and Junk in Roundcube first. Then Edit or Delete a Discard rule that is too broad.
  • The same message is handled twice: you may have both a filter and a forwarder on that address. Remove the extra one.
  • Global and per-mailbox rules clash: check Global Email Filters as well as the account's own list.
  • Unsure which product or DNS the domain uses: open a support ticket and we will check with you.

Related


Was this article helpful?

← Back to cPanel