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?

8 Answers 8


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.

  • 3
    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, 2010 at 17:49
  • 1
    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! Jul 1, 2013 at 16:05
  • 1
    @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. Jul 2, 2013 at 14:26
  • 1
    @LimitedAtonement: so, all you need to be happy is a "after the search click 'create filter'" statement somewhere?
    – akira
    Jul 2, 2013 at 15:22
  • 12
    To clarify for anyone who might run into this: "OR" is case sensitive (i.e. "or" won't work).
    – kevinmicke
    Feb 21, 2017 at 22:58

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 [email protected] in the To field, it'll create the filter condition to:([email protected]). 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:[email protected] OR from:[email protected]

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.

  • 4
    This should be the accepted answer. Using the workflow in akira's answer does not work, because the search criteria get mangled as soon as you click on "create filter with this search". Advanced boolean expressions are left untouched only when using the "Has the words" field, like suggested in this answer. Sep 23, 2016 at 22:37
  • Use Has the words field is the correct one. Ex: from:[email protected] OR to:[email protected]
    – vNext
    Mar 15, 2020 at 14:39

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.


[email protected] | [email protected] | [email protected]`

The search box would look like:

to:([email protected] | [email protected] | [email protected])

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


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)


You can group them:

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


The best way I've got to work for the to field is:

to:({[email protected] [email protected] [email protected]})

You need to use has the words input field instead. This will let you update existing filters instead of deleting and creating new ones.

Example: from:(sas.com) OR to:(sas.com)


Either A OR B and A | B work for me.

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