What's That Noise?! [Ian Kallen's Weblog]

« Blinkin' Blog | Main | Technorati Japan »

20050529 Sunday May 29, 2005

Thwarting Spam With GMail and Procmail I've been self hosting my mail for almost 10 years now and I'm not about to quit. But the growing ineffectiveness of SpamAssassin has made me consider it. While SpamAssassin was catching a lot of spam, at least as much was still getting through. It'd really gotten a lot worse lately. I probably could have done more with it (and I may still dig deeper into how to configure SpamAssassin to work better for me) but I was intrigued by the idea of using a web mail host as a pass-through service to do it for me.

I've used GMail since last summer but really haven't had a whole lot need for it... it's a nice place to subscribe to mailing lists from. When I'd read Using Gmail as a Spam Filter a while back it intrigued me but the idioscyncrasies of procmail and qmail made it seem like more of project than I'd wanted to undertake (yea, yea... one of these days I'll migrate to postfix but I have a lot of legacy ezmlm stuff running, I need to figure out how to migrate that to mailman or something).

Well since I had a ton of GMail invites sitting around, I invited myself to create another account (one that no spammers will know the name of, I hope... we'll call it gmail.username for now). I followed the GMail side of the instructions at the site above, e-z nuf. And then I got to the stuff on my server. This is what I ended up doing in my procmailrc to get procmail to forward a message and accept it again once GMail took its turn on it:

:0 
* ! ^X-Forwarded-For: gmail.username@gmail.com my.username@my.domain.com
| /usr/bin/formail -R Delivered-To X-Delivered-To | \
/usr/sbin/sendmail -oi gmail.username@gmail.com
I probably could've used qmail-inject instead sendmail but whatever, this works. So what's up with the pipe to formail -R Delivered-To X-Delivered-To?
Well, without it qmail got very grouchy. Well, grouchy in that inimitable qmail'ish way:
Hi. This is the qmail-send program at my.domain.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<my.username@my.domain.com>:
This message is looping: it already has my Delivered-To line. (#5.4.6)
OK, so qmail's loop detection worked a little too well for me; I worked around it by munging the Delivered-To line.

My vindication came in the hours that followed as dozens of pieces of junk messages ended caught by GMail's spam detection and the mail that I wanted got through to me on my longstanding but spam-threatened email address.

Warning: if you want to email me something without Google knowing about it (i.e. say you have a business proposition that is a "google killer"), ask me for some alternate methods.

( May 29 2005, 01:02:26 AM PDT ) Permalink


Comments:

Post a Comment:

Comments are closed for this entry.