How to Filter Mail Using a Custom Header in Mac OS X Mail
You can teach OS X Mail use any header line for email filtering.
The Rule of Sender and Subject
Much email filtering can be accomplished by looking at the sender, the recipient or the subject of a message. These header fields are also the choices Mac OS X Mail gives you by default when you set up a new rule.
What if you want to look for a custom header, though, an "X-Text-Classification" header added by POPFile for example, something specific in an email’s “Received:” lines or a redirect perhaps? Mac OS X Mail can search and filter based on these headers, too. First, you have to tell it for what to look, though.
(If you are unsure what header lines your filter could use, you can always take a peek and look in OS X Mail itself: revealing the full header lines for any message is easy, and you can access the full message text—including all headers—as well, if you prefer.)
Filter Mail Using a Custom Header in Mac OS X Mail
To set up a rule looking for a custom message header in Mac OS X Mail:
- Select Mail | Preferences... from the menu.
- Go to the Rules category.
- Click Add Rule.
- From the From drop-down menu, choose Edit Header List....
- In Mac OS X Mail 2 and later:
- Click +.
- Type the desired custom header (such as "X-Text-Classification").
- In Mac OS X Mail 1:
- Type the desired header ("X-Text-Classification", for example) under Header:.
- Click Add Header.
- Now click OK.
- Select the newly added header from the From drop-down menu.
- Finish creating your filter.
Get Rid of a Custom Header for Filtering
To remove a custom header from Mac OS X Mail’s rule setup:
- Go to the custom header list as if adding a new header.
- Double-click the custom header you want to remove.
- Press Del.
- Press Enter.
You Can Do More with Rules in OS X Mail
Mac OS X Mail’s filters are useful all around, of course. You can set up rules to block senders and domains (or whitelist them), for example, or to create an auto-responder that replies to incoming emails automatically—while you are away or to set expectations when you will be able to reply. In combination with Mail Act-On, OS X Mail can apply rules and actions to the emails you send as well. (In case you are not so keen on seeing Apple newsletters highlighted in your inbox, you can disable OS X Mail’s example rule that does just that.)
Of course, you can also teach the junk mail filter built into OS X Mail—without maintaining any rules.
Was this answer helpful?
Blocking a sender is easy in OS X Mail, and particularly so if you have a message from them at...
macOS Mail and OS X Mail can show you all an email's header lines—which contain possibly...
If you have more than one account (or more than one address per account) in Mac OS X Mail you can...