How to use "not" in Gmail filters? [closed]

Solution 1:

Fixing this problem requires understanding two things:

1) If a label has been placed on an existing email by a filter, the label stays even if that filter were deleted. One must delete the label itself, and then re-create a new filter in order to get your edits to "take".

2) There is a bug in the Gmail filter system. If you try to set up complex Boolean such as

from:[email protected] -to:[email protected] -junk_term

It will work fine on the initial search, but if you use it to create a filter, the terms, especially the NOTs, will be garbled.

The correct syntax, (hat tip to chenghuayang) is to ignore the to's and from's.

[email protected] [email protected] -junk_term

Solution 2:

You could use labels to flag your emails and process them accordingly, based on those labels:

  1. matches from: [email protected] then apply label Label_X
  2. matches from: [email protected] then apply label Label_Y
  3. matches junk_term then apply label Label_Y
  4. matches label:label_X AND -label:Label_Y then respond

The condition of the last rule has to be added to the Includes the words field.

Here is a list of further attributes.