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?


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.

| improve this answer | |
  • 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 '10 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! – Limited Atonement Jul 1 '13 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. – Limited Atonement Jul 2 '13 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 '13 at 15:22
  • 5
    To clarify for anyone who might run into this: "OR" is case sensitive (i.e. "or" won't work). – kevinmicke Feb 21 '17 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 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.

| improve this answer | |
  • 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. – Marco Leogrande Sep 23 '16 at 22:37
  • Use Has the words field is the correct one. Ex: from:info@some-domain.com OR to:info@some-domain.com – vNext Mar 15 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.


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.

| 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)

| improve this answer | |

You can group them:

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

| improve this answer | |

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

| improve this answer | |

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

to:({first@email.com second@email.com third@email.com})
| improve this answer | |

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)

| improve this answer | |

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