I was trying to create some complicated Gmail filters. However, there doesn't seem to be any documentation of how the
from fields work exactly. So I tried figuring it out myself...
General Matching Guidelines
The matching criteria is similar to Google's search. There is no word stemming, so you must enter full words (e.g.
joh will not match
firstname.lastname@example.org). Not even plural stemming, like what Google search has, is supported (e.g.
app will not match
Word order does not matter, unless the words are enclosed in quotes (e.g.
"smith john" will not match
email@example.com). Generally, symbols are ignored (for more information see the next section).
Words are split on everything except: letters, numbers, and underscores. The most common symbols that split words are
+.@. This means that
foo will not match
firstname.lastname@example.org but will match
@ character itself is not considered a word and can be skipped over (e.g.
"smith gmail" will match
You can use the
OR operator in addition to grouping
() for some complex conditions.
When you enter a symbol in the filter box, they usually behave differently:
- Symbols that act as
~#$%^*+;",<>?and the grave character. For example,
smith john, which matches
- Symbols that act as
-=\:'./-- For example,
"john smith", which matches
- Symbols that are treated literally:
&_-- For example,
email@example.com, but not
- Special symbols:
john -smith, which matches
@is stripped out at the end of a word. For example,
john, which matches
@is stripped out at the start of a word. For example,
foo.com, which matches
@in the middle of a word will generally require the full address for a successful match. For example,
john.smith@gmailwill not match
firstname.lastname@example.org. Additionally, symbols will be taken literally. For example, to match
email@example.com must use
firstname.lastname@example.org no longer work.
@in a different location in the middle of a word has strange behavior. For example, when trying to match
john@smith@gmail@comdoes not match
gmail@comdoes not match
@gmail@comdoes not match
email@example.com not match
"john firstname.lastname@example.org"does not match
"john.smith@gmail com"does not match
|acts as the
- Parenthesis act as grouping for
Other Matching Behaviors
The default account you use (e.g.
email@example.com) will match all variations of your address. This includes dot notation, plus addressing, and using the googlemail.com domain.
Here's a brief explanation of each:
- Using dot notation: You can enter as many non-consecutive dots in your email as you want. For example, if your email is
firstname.lastname@example.org, mail sent to
email@example.com still arrive at your account.
- Using plus addressing: After your account name, you can enter the
+sign and whatever text you want afterwards followed by the Gmail domain. For example, mail sent to
firstname.lastname@example.org arrive at
- Using googlemail.com domain: Any mail sent to your
<your-gmail-account>@googlemail.comwill arrive at your
@gmail.comaddress. For example, mail sent to
email@example.com arrive at
Any of the above can be combined (e.g.
firstname.lastname@example.org will still go to
- Can't match all dot versions of your Gmail address easily: If you're in the habit of giving out the
.version of your email address to prevent spam (e.g.
email@example.com), you cannot easily create a filter for all dot version of your address since these are split up into separate words (e.g.
smith). When you only use one variation of this, it's easy to create a filter and, for example, send it to spam. However, if you start using different variations (e.g.
firstname.lastname@example.org) it causes different words in the address (e.g.
th), forcing you to create a distinct condition for each variation you use.
+symbol is worse than the
""operator when matching plus addresses: If you're trying to create a filter for a plus address, your best bet is to include the full address (e.g.
email@example.com). If for some reason you aren't using the full address, the
+operator is actually worse than the
""operator. For example,
john+foois worse than using
"john foo", since the former will match
firstname.lastname@example.org. Keep in mind that the later is not bullet proof either, it will still match
email@example.com. It just guarantees that the order is correct. For clarity, you could use
"john+foo", but realize that it's the same as
- You must use negation to match all email sent to plus addresses: To filter on all plus addresses (e.g. to send them to spam), you should use the query
firstname.lastname@example.org -"john smith gmail com". The first part of the query will match any plus addresses you have. The second will remove all those that don't have the words in the exact order. For example,
email@example.com not match since it has the word
fooin between the other words. Note that there is one weird, and very unlikely, case where this won't work:
firstname.lastname@example.org, since it does have the words in the specified order.