Archive

Posts Tagged ‘gmail’

Filter Spam by Language in Gmail

May 13th, 2009 4 comments

DISCLAIMER: This post is not at all Ubuntu-specific, but it is Ubuntu-applicable. This tip will actually work on any platform as it is Gmail specific, and I know many of you are big Gmail fans.

I have had my Gmail account since the time of the earliest invites, and my email address is splattered all over the web these days. From site registrations to mailing lists, from stupid forward chains I got pulled into to.. well, you get the idea. The result of this is that I get A LOT of Spam in my Gmail account. Now, to Gmail’s credit, the vast majority of it gets deleted or put into my Spam folder automagically. I’m talking ~1000 emails into my Spam/Trash folder within a 24hr period. It’s ridiculous!

Recently I have been getting more and more Spam directly into my Inbox, so much in fact that I have all but abandoned my Gmail account for a new, personally hosted IMAP server. I had decided that, pending a solution to this rampant Spam, I would have to use something else. Well today I think I found that solution.

I was mentioning on Identi.ca that I wish Gmail had a language-based filtering option. Well, it turns out that they do, and that makes filtering foreign-language Spam a breeze!

Here are the steps I took toward creating a Russian-language filter:

  1. Click “Create Filter” located at the top of your Inbox
  2. In the “Has the words:” field, enter: lang:Russian
  3. Select “Delete it” within the Action List, and (if you have existing Russian Spam) select: “Apply Filter to Conversations below”
  4. Click “Create Filter”

I have only tested this briefly, but so far it has worked to filter out and clean up existing Russian (lang:Russian) and Chinese (lang:Chinese) Spam. I’m sure other languages work just as well.

I would suggest, before you “Apply Filter to Conversations below”, that you take a look at the matches. If you are on mailing lists, or have correspondence with international developers or community members, it could match their emails as well. Just be careful you don’t accidentally filter out emails you want!

If you have any other tips regarding Gmail Spam filtering please share them in the comments.

Categories: Internet Tags: , , , ,

Relaying Postfix SMTP via smtp.gmail.com

November 11th, 2008 43 comments

I’ve got a few servers in different places around the country and try to monitor them using the logwatch utility.  One problem that I’ve run into however is that a few of these servers are not able to send their logwatch emails to me, based on email restrictions by the ISPs.  I spent some time this afternoon researching what was required to have my servers authenticate to my gmail account and send me the mail that way.  This setup assumes Ubuntu 8.04 (or later) and Postfix.

Install the required packages

sudo aptitude install postfix libsasl2 ca-certificate libsasl2-modules

Configure Postfix

This tutorial will not outline how to configure your postfix server, but we’ll jump directly to the relayhost section.  You’ll want to add the following lines to your /etc/postfix/main.cf file:

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

The above lines are telling Postfix that you want to relay mail through gmail on a specific port, telling it to authenticate, and where to find the username and password.  The last three lines specify the authentication types supported, where the certificate authority file is and that it should use tls.

Define Username and Password

Next we’ll need to populate the sasl_passwd file.  Create the file /etc/postfix/sasl_passwd with the following contents:

[smtp.gmail.com]:587    user.name@gmail.com:password

This file should have restrictive permissions and then needs to be translated into a .db that Postfix will read.

sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd

At this point you can restart Postfix and it should work, however it will complain about not being able to authenticate the certificate.  To take care of this issue we’ll use the ca-certificate package we installed and tell it where it can validate the certificate.

cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

Go ahead and reload postfix (sudo /etc/init.d/postfix reload) and you should be set.

Categories: EMail Tags: , , ,