Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I filter messages in Gmail using boolean OR conditions? For example, I can specify addresses in the To: or From: fields, but this only matches emails that meet both criteria. How can I match emails that meet one or both criteria?

share|improve this question
up vote 53 down vote accepted

Type into the search field of Gmail:

from:xyz OR to:uvw

see also here.

to make a filter (and apply actions to that filter) from that search: click the little down arrow on the right side of the search field and then click create filter with this search.

share|improve this answer
Thanks. You've saved me a lot of frustration. I have a friend who doesn't know about the BCC field and likes to email TONS of people who like to reply-to-all. – jessegavin Jul 19 '10 at 17:49
At first I thought this answer is correct, but now I see that OP asked about filtering, and you said "type into the search field." Now my vote goes to Senseful. Good, succinct answer, though! – Limited Atonement Jul 1 '13 at 16:05
@LimitedAtonement: i do not understand your comment. – akira Jul 2 '13 at 6:25
@akira The OP asked about filtering email messages (which I read to mean applying inbound filters), and your answer is about searching for email messages. – Limited Atonement Jul 2 '13 at 14:26
@LimitedAtonement: so, all you need to be happy is a "after the search click 'create filter'" statement somewhere? – akira Jul 2 '13 at 15:22

If you are talking about searching, then @akira's question is correct. However, it sounds like you are asking about how to use this condition in a filter.

The trick is that you can put whatever search criteria you want in the filter's Has the words field. For any other field it will prefix your criteria with the field name. For example, if you type user@example.com in the To field, it'll create the filter condition to:(user@example.com). The reason it works in the Has the words field, is because it doesn't prefix it with anything. This is because it acts as a normal search on the content of the email.

  1. Create or modify a filter.
  2. In the Has the words field, enter your OR condition. For example: to:user@example.com OR from:user@example.com

This is also the place to put any other attributes you want to match (e.g. label:, in:, etc.).

This will also work in the Show search options page, however it's easier to just use a normal search instead.

share|improve this answer

To my surprise, the solution to me was using the vertical bar | between emails instead of the comma , in the TO filed during filter creation.


name1@domain.com | name2@domain.com | name3@domain.com`

The search box would look like:

to:(name1@domain.com | name2@domain.com | name3@domain.com)

I got a popup message from Gmail saying that using special characters may give unexpected results. Just clicked on continue and it worked perfectly.

share|improve this answer

Gmail accepts several syntaxes:

apple OR orange apple | orange {apple orange}

Personally, I like to use the curly braces because it is nice and concise. The following are all equivalent:

from:{john jane joe} {from:john from:jane from:joe} (from:john OR from:jane OR from:joe}

share|improve this answer

You can group them:

{"Words1" AND "Words2"} OR {"Words1" AND "Words3"} etc...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.