Sunday, October 7, 2012

Google Gmail Filters: Unleash the Power

Problem

For many weeks, I was receiving at least one and later two e-mails a day from a spammer using the comment section of my Google blog site to lure me into visiting his or her many web sites. That might not sound like much, but that amounted to 30-60 unwanted e-mails per month. While I welcome genuine comments about my blog postings, I do not welcome people trying to generate business for their commercial web sites or even worse, trying to sucker me into visiting a malicious, virus-infected site.

I have been using Google e-mail filters for a long time, but this situation posed a new problem. All offending e-mails contained a variation on a common theme: some mention of a blog site, web page, or home page followed by a url. I certainly did not want to create a separate filter for each individual phrase. Instead, I needed to consolidate those multiple conditions into a single filter field, something I had never done before.

Solution

To access Google's Gmail filters, open Gmail and then:
  • Click the "Settings" cog near the upper right corner
  • Select the "Settings" menu option from the resulting pull-down menu.
  • Select the "Filters" label from the menu options across the top
  • Click on the "Create a new filter" link at the bottom
There are five e-mail filtering categories: From, To, Subject, "Has the words" and "Doesn't have." You may create entries in more than one category suitable for your needs.

All of the obnoxious e-mails, originating as they did from my Google blog site, contained the sender
"noreply-comment@blogger.com"
so that became the sole entry in my filter's "From" field.

The key, of course, becomes the "Has the words" field. I needed to include several different alternatives utilized by the spammer. After poking around Google search for a little while, I found something that worked. The key to multiple values is the following syntax:
enclose the entire expression in { } curly brackets, and then within those brackets, enclose each individual expression in " " double quotes.
The curly braces indicate an OR condition where any one of the conditions will trigger the filter. Simple parentheses ( ) indicate that all of the specified conditions must be present, not just one. As an alternative, users can forego the braces and parentheses altogether and instead place AND or OR between the conditions (making sure to preserve the capitalization). Both alternatives work equally well.

Bingo! The following example worked like a charm:
{"my web blog" "my weblog" "my blog" "my web page" "my webpage" "my home page" "my homepage" "my site" "my web site" "my website"}
The following example also works:
"my web blog" OR "my weblog" OR "my blog" OR "my web page" OR "my webpage" OR "my home page" OR "my homepage" OR "my site" OR "my web site" OR "my website"
I lean towards the first example if only because it is slightly more compact.

In addition to my sender criterion, I also placed the above compound expression into my "Has the words" field, set my disposition instruction to delete all e-mails, and saved the filter settings. Now, instead of receiving one or two offending messages each day, I have not received a single one in over a week. The filter's syntax clearly works.

[Side note: I have since relaxed my disposition to send the e-mails to the trash bin instead of immediate deletion. By doing so, I can monitor the trash bin occasionally to determine if the e-mails are still arriving while simultaneously confirming that my multiple conditions are indeed still working properly.]

Postscript

Google apparently imposes no numerical limits on its users. Even so, it seems far more economical to create one filter with multiple conditions rather than multiple filters each with one condition. In general, it is far easier to manage a smaller number of filters even if those filters have multiple conditions.

By contrast, Yahoo's mail limits its e-mail users to 100 filters. (Cheer up: only a few years ago, the limit was just 20.) Yahoo offers four categories (sender, recipient, subject, and body) on which to filter. For each of those four options, users may select "contains, "does not contain," "begins with," or "ends with."

Alas, despite some claims that Yahoo's conditions recognize Boolean operators such as "AND" and "OR," I could never get them to work. I tried the OR condition both lower case and upper case (as in Google searches); with and without the brackets (and plain parentheses, also like Google searches); and with and without the double quotes. All combinations failed miserably.

To me, the inability to express multiple conditions within a filter is a fatal flaw, especially when you have only a limited number of filters available.

No comments:

Post a Comment