hoodwink.d enhanced
 

juretta.com

Using Spamassassin with Rails ActionMailer | November 25, 2006-->

November 25, 2006

Running attachr.com for quite a while i noticed that the email service (you can send an email to save@attachr.com to save a code snippet) became target for spam mails.
I decided to install spamassassin to mark incoming emails for the ActionMailer service that inserts email entries into the attachr.com database.

Running a decent Debian webserver the whole task took only about 10 minutes.

First, install spamassassin
attachr:~# apt-get install spamassassin

You need to enable spamassassing in /etc/default/spamassassin.

attachr:~# vim /etc/default/spamassassin
# /etc/default/spamassassin
# Duncan Findlay

# WARNING: please read README.spamd before using.
# There may be security risks.

# Change to one to enable spamd
ENABLED=1
# ^^^^^set ENABLED to 1

Start the Spamassassin Daemon:

attachr:~# /etc/init.d/spamassassin start

To filter every incoming email with spammassasin the alias file (/etc/postfix/attachr looks like this:

cat /etc/postfix/attachr
save: "|/usr/bin/spamc|/path/to/app/script/runner 'EntryMailer.receive(STDIN.read)'" 

Spamassassin marks every email with additional mail header fields (X-Spam-...). Email marked as Spam has a X-Spam-Status header field like this:

X-Spam-Status: Yes, score=7.0 required=5.0 tests=FORGED_MUA_OUTLOOK,
The Ruby code handling inbound mails has an "email" object containing the incoming email. The "x-spam-status" field contains the header value. Just match a /^Yes/ to flag the incoming mail as spam (attachr.com just ignores entries flagged as spam).
spam = true if email["x-spam-status"].to_s =~ /^Yes/

Diggman

About

juretta.com is the personal workspace of Stefan Saasen. You can send him an email or read more about this site in the „About“ section.

« Previous entry

Add generated Rails files to SVN
posted about 1 year ago

» Next entry

RubyOSA - Ruby/AppleEvent Bridge
posted about 1 year ago

Recent comment

On: “Attachr.com: OpenID support added

You need to kill this spam stuff!

posted about 1 year ago by entropie

Look!

Latest links  RSS  

More...