Using Gmail as a Spam Filter
If there’s one thing Gmail knows, it’s spam. Hosting millions of email addresses means millions of spam messages arrive every day-and Google must unleash their minions in the never-ending battle to stop that stuff from getting into your Inbox.
So, Gmail’s spam filters are really good, and with a little bit of cunning technique, you can use the system to filter all of your mail, and not just Gmail.
You can do this because Gmail allows you to forward messages. This is a little bit complicated, so bear with me. Here’s what to do:
Go to the Settings page, and click on the Forwarding tab, and set Gmail to forward all messages to your non-Gmail account (from now on referred to as example.com).
Once you’ve done that, all messages to gmail.com will go to example.com, except for the spam, which will be filtered.
Now, go to over at your example.com mail server, and create a filter to check the headers of any incoming e-mail. Have it forward to your Gmail account if it does not find the following in the header:
X-Forwarded-For: user@gmail.com user@example.com
There are many ways of doing this, and you’d be wise to ask your system administrator to advise you on it. For really advanced users, a procmail filter to do this would look like this (with your Gmail account and real mail server replacing user@gmail.com and user@example.com in the obvious places):
:0
* !^X-Forwarded-For: user@gmail.com user@example.com
! user@gmail.com
When this is set up, your server will send all the mail that Gmail hasn’t seen to Gmail. Gmail will filter it for spam, and then pass it back, having added in the header. The filter ignores all the messages with the header, and so all you see in your example.com account is beautifully filtered mail.
This technique also has the advantage of saving a copy of all of your mail within Gmail - handy for backups. And remember, if you use Gmail as your SMTP server too, then all your outgoing mail will be saved also.
An Even Simpler Way Of Doing It
There is, naturally, an even easier way of doing this. Justin Blanton, this tome’s noble technical editor points out that if you can’t set server side filters, but can create multiple mail accounts, you can do the following:
- Create a new mail account (the username doesn’t matter; no one will see it).
- Forward the e-mail from your current account to Gmail.
- Forward your Gmail e-mail to the account you just created.
- Gmail will filter your e-mail before forwarding it along.
- Use your new mail account (you’ll obviously want to set the "reply-to" and "from" fields to your current address and not the one you just created).
Popularity: 2% [?]