Quick guide for installing SpamAssassin as a service

I was having some issues with spam on my mail server (hMailServer), so I decided to set up SpamAssassin to filter things before they hit my inbox. While hMailServer has some native support for SpamAssassin, I figured I would write up the steps I used to get things running smoothly as a Windows service.

Note that this is on a Windows Server 2003 box – steps may vary for other versions.

  • Download and install the Win32 binaries for SpamAssassin from JAM Software. This includes the spamd daemon, but this normally runs as a command-line application. It is better to run it as a Windows service, so it can be launched automatically when the machine reboots, without having to log in and run it manually.
  • Install the Windows Server 2003 Resource Kit Tools, if you haven’t done so already. This contains the srvany tool, which can be used to run an application as a service.
  • Open a command prompt for the Resource Kit Tools. There’s a shortcut installed with the tools.
  • Run instsrv SpamAssassin <path to Resource Kit Tools>\srvany.exe. This will install a new “SpamAssassin” service, linked to the srvany tool.
  • Now, open up the registry editor (regedit). Create a new key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SpamAssassin, called Parameters.
  • Under the Parameters key, create a string value called Application. Set the value of this to <SpamAssassin path>\spamd.exe.
  • Under the Parameters key, create another string value called AppDirectory. Set the value of this to <SpamAssassin path>.
  • Go to the Services administrator tool, and start the new SpamAssassin service you created.
  • Now, open up the hMailServer administrator tool, and go to Settings\Anti-spam. Click on the SpamAssassin tab, and check the Use SpamAssassin checkbox. Fill in the appropriate hostname (localhost should be fine, although you can use if that doesn’t work), and check the Use score from SpamAssassin box. Finally, click on the Test… button to test your configuration. If a dialog box shows up with a response from the SpamAssassin service, you’re good to go.
  • If not, check to make sure that the service is running, and that the port used (783, by default) is not blocked. Check to see if the port is being used, by running netstat –an and checking to see that something (the spamd daemon) is using TCP port 783. You can also try enabling logging with spamd by creating an AppParameters string value under the registry key mentioned above, and setting it to –s file. This should result in a spamd.log file being created in the same directory as spamd.exe, and the information within might help you debug the issue.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.