How to create email filters in cPanel
Help centreOn this page
This guide shows how to set up email filters in cPanel so incoming messages are sorted, passed on or thrown away automatically, before they reach your inbox.
Two places to make filters
cPanel has two filter tools in the Email section:
- Email Filters works on a single mailbox. Use it when one person wants their newsletters moved into a folder, or wants mail from a certain sender deleted.
- Global Email Filters works on every address on your account. Use it for rules that should apply to everyone, such as binning mail from a domain that keeps sending junk.
Filters run on the server as each message arrives. That means they work the same way on your phone, your computer and in webmail, and they still work when no email program is open.
How a filter is built
Each filter has a name, one or more rules and one or more actions.
A rule looks at part of the message and checks it. You pick what to look at (for example From, Subject, To or Body), how to compare it (for example contains, equals, begins with or does not contain), and the text to compare it with. You can add several rules and join them with and or or.
An action says what happens when the rules match. The common ones are:
- Deliver to Folder moves the message into a folder in that mailbox.
- Redirect to Email sends it on to another address.
- Discard Message deletes it without telling the sender.
- Fail With Message rejects it and sends the sender an error.
- Stop Processing Rules stops any later filters from running on that message.
Create a filter for one mailbox
- Log in to cPanel. See how to log in to cPanel.
- Open Email Filters in the Email section.
- Find the address in the list and click Manage Filters next to it.
- Click Create a New Filter.
- Give the filter a name you will recognise later, such as “Supplier invoices”.
- Under Rules, set the first rule. For example, choose From, then contains, then type
accounts@supplier.co.uk. - Click the + button if you need another rule, and choose and or or.
- Under Actions, choose Deliver to Folder, click Browse and pick the folder. Create the folder in webmail first if it doesn’t exist yet.
- Click Create.
Create a filter for the whole account
- In cPanel, open Global Email Filters.
- Click Create a New Filter.
- Name it, then set the rules and actions as above.
- Click Create.
Be careful with Discard Message in a global filter. A rule that is too broad, such as a subject containing “invoice”, could quietly delete real mail for everyone. It is safer to move matching mail into a folder for a week first, check what lands there, then switch to discarding.
Test a filter before you rely on it
cPanel can check a filter against a sample message without sending anything.
- On the filter list page, scroll down to Filter Test.
- Paste in a sample message, including the header lines you are filtering on. For example:
From: accounts@supplier.co.uk
Subject: Invoice 1042
Test message body.
- Click Test Filter.
- Read the result. It tells you which filters matched and what action would be taken.
You can also send a real message from another account and see where it ends up.
Filters in webmail
Roundcube webmail can link to the same server filters, depending on how the webmail is set up. If you see a filters option in webmail settings, the filters you make there apply to that mailbox only. If you don’t see one, use Email Filters in cPanel, which works for every mailbox. See how to log in to webmail.
Rules made inside Outlook, Apple Mail or Thunderbird are different. They usually only run while that program is open on that device, so a server filter is more reliable.
If it doesn’t work
- The filter does nothing. Check the spelling of the text in the rule. equals needs an exact match, so contains is usually the better choice.
- Mail lands in the wrong folder. Another filter may be matching first. Filters run in order, top to bottom. Drag them into a different order on the list page, or add Stop Processing Rules to the filter that should win.
- Matching on From doesn’t catch everything. Some senders use several addresses. Match on the domain part, such as
@supplier.co.uk, instead of the full address. - Redirected mail doesn’t arrive. Large providers sometimes reject redirected messages, especially spam. A forwarder may suit you better. See how to forward email.
Related guides
Still stuck? Open a support ticket and we’ll help.
Mailboxes on UK servers that work on your phone, in Outlook and in webmail.