WordPress SpamAssassin Plugin

The latest version of the plugin is 0.6.2 released 6 Feb 2005. It has been relegated to the dustbin of history by Bad Behavior and therefore is no longer available. Users of this plugin should migrate to Bad Behavior as soon as possible.

People who are still interested in using SpamAssassin on blogs should investigate BlogSpamAssassin.

Why SpamAssassin? What’s SpamAssassin?

I hate spam. I really hate spam. And I hate comment spam on my blog. I thought I was fairly well protected against comment spam, but the spammers are getting smarter. So I decided to raise the stakes a bit. Introducing the WordPress SpamAssassin plugin.

SpamAssassin is a nice program designed for ISP mail servers that immediately rejects incoming spam before it ever gets anywhere near your inbox. However, it also has its own wire protocol, so you can write custom programs to speak to it. And that’s exactly what I did.

This plugin filters all of your blog comments through SpamAssassin, recognized as the Internet’s best spam killer. If you are using WordPress 1.5, it will also filter all of your trackbacks and pingbacks. It is so good at sorting spam from legitimate mail that adapting it to blogs seemed like a natural thing to do, especially since I ran into trouble with every other solution out there.

Features

The WordPress SpamAssassin Plugin feeds all of your blog comments (and with 1.5, trackbacks and pingbacks) to SpamAssassin for analysis. Messages which aren’t spam are allowed through. Messages which are suspicious are sent to the moderation queue, and those which are certainly spam are discarded entirely. A message will be written to the error log (or syslog, depending on your PHP configuration) whenever SpamAssassin screens a comment.

Requirements

The prerequisites for running the WordPress SpamAssassin Plugin are:

  • PHP must be built with sockets support. Check phpinfo() if you are unsure whether your version of PHP includes sockets support.
  • WordPress 1.5 and later are fully supported. In WordPress 1.2/1.3 only comments will be screened.
  • SpamAssassin 2.0 or later is required; 3.0 is recommended. It does not need to be running on the same server as your blog.

Installation

You will need to have a running SpamAssassin server in order to use this plugin. Your web hosting provider may already be running SpamAssassin for their mail; contact them to find out the hostname for the SpamAssassin server and fill this in to the plugin. It’ll probably be the same as your SMTP server. If you’re self-hosted, you need to install SpamAssassin on your server, if it isn’t already installed. Some distributions of Linux include it, for instance.

After determining where your SpamAssassin server is, edit the wp-spamassassin.php file and place its location in the appropriate place. To support suspicious message moderation, we add a spam tag to any suspicious message. You will need to add this tag to your moderation keywords. I don’t currently do this automatically, so as to avoid inserting blank lines, removing your other entries, etc. There are also a few other customizations you can make there. Upload the file into your wp-content/plugins directory and activate it. That’s it!

Thanks

Thanks to the following people for their contributions of ideas, feedback, code, cash, etc.:

Change Log

Trunk
Cooperate better with other plugins that screen comments, i.e. don’t approve a comment if another plugin marked it as spam, etc.
0.6.2
Fixed a problem on WP 1.5 causing all trackbacks to be approved, even when they should not be.
0.6.1
Fixed a problem causing comments to be saved to the database, but never to appear on the site or in the moderation queue. All users should update.
0.6
Added the ability to send a post to moderation without tagging it on 1.5. Requires a recent nightly.
0.5
Rewrote much of the code in order to fix a problem with false positives when using WP 1.2.
0.4.1
Placed a workaround for a common PHP misconfiguration.
0.4
Added activity logging. This is done through the PHP error logging mechanism as it’s the only reliable way of doing so across platforms.
0.3
Added moderation for suspicious comments.
Added UNIX domain socket support.
Improved the message format passed to SpamAssassin.
0.2
Improved the message format passed to SpamAssassin.
Fixed a Windows PHP bug in the sockets code.
0.1
Initial release.
Copyright © 2010 Homeland Stupidity.