This is pretty geeky, but I’m proud, dammit. So who cares.

I learned how to write spam filters for Spamassassin in Perl regular expressions. The problem was that I was getting tons of spam bounced to me by mail servers. Seems that someone has put my domain on a list of domains that spammers can use to send mail from. I was getting all kinds of “undeliverable” error messages addressed to things like jdfksajf @ and popoijh @ The original messages were sent by spambots that were using random addresses from my domain, and naturally the bounces would come back to me. I’d wake up with about 30 of these damn things in my inbox. Since the addresses were random, it was pretty difficult to filter them. I could filter all mail with the words “undeliverable” or “failure” in the subject, but then I might miss out on actual bounce messages for mail that I really did send.

What I needed was a filter that would detect if a message did not come from my real email address, and then automatically delete it if it appeared to be a bounce message:

header __MY_ADDRESS To !~ /
header __UNDELIV01 Subject =~ /undeliverable/i
header __UNDELIV02 From =~ /postmaster/i
header __UNDELIV03 From =~ /daemon/i

That was the result of a couple of hours of wrapping my puny brain around a few pages about writing Spamassassin filters and regular expressions. Maybe someone will Google it and find it useful. If you did find this in Google, just edit the filter to put your real email address in there instead of the fake one I used (duh). You can also add more numbered __UNDELIV filters as you find necessary. The double underscores at the beginning are important for these, so don’t omit them. 🙂