Post.Office & SpamAssassin (Rewrite Subjects and Spam Reports)

Post.Office Tips & Tricks: Index

Tenon added SpamAssassin support to Post.Office in version 3.5.3 (build 720). SpamAssassin works quite nicely once you've set it up and configured but the Post.Office SpamAssassin module has a few drawbacks. One of the most serious shortcomings is that you can't get any header rewrites through the module. The SA-module just reports to Post.Office if a message is spam or not but doesn't allow for the original message to be modified.

This is where my script comes in.


How this script works

A cron job is executed every hour to scan the local spam-catcher mailbox and then redistributes any found messages to the right user folder.

In order to use this script, you must copy all spams to a local spam-catcher mailbox. This is done by creating a new Post.Office user account on your server with a POP3 mailbox. After you've done that, you should change the SMTP-Filter setting in Post.Office to copy filtered messages to the newly created account.

The script can just rewrite the subject to make it easy to indentify the spam or it can run SpamAssassin again to use the full SpamAssassin report features. This is all done before the script puts the message back into the local user mailbox.

New version: 0.21 - November 29th, 2004 - spamsortnew.sh

The new version has several enhancements. However the configuration wizard and in-depth documentation are not yet available.

This version has these additional features:


Current version: 0.1 - updated 29th January 2004


Features

Here are the features of the script:

And best of all, there is an online configurator/wizard for the script which allows you to set your preferred configuration without having to wade through code of my shell script.


System Requirements

This script has been tested on MacOS X 10.2.x and is currently running a our mail server (MacOS X 10.2.8) without any problems.


Installation

Here's a quick installation guide:

  1. use the online configurator to adapt the script for your system or download the default script
    (You won't need to edit the script in a text editor afterwards.)
  2. copy the spamsort.txt file to the top level of your server
  3. open your Terminal application
    /Applications/Utilities/Terminal.app
  4. change to the root user by typing the following after root#
    su -
  5. move spamsort.txt from the top level to the root home directory
    mv /spamsort.txt ~/spamsort.sh
  6. go to the root home directory
    cd ~root
  7. change the file permissions of spamsort.sh to make it executable
    chmod 755 spamsort.sh
  8. change the file ownership of spamsort.sh
    chown root:wheel spamsort.sh
  9. run the spamsort script for the first time manually
    ./spamsort.sh
    This will take some time as it checks all files in your spamcatcher mailbox for a first time. It will also show any errors that could occur. After the first run, the script will only verify the newest files since the last execution.
  10. Append your list of cron jobs ( /etc/crontab ) to execute the spamsort.sh every hour
    echo "0 * * * * root ~root/spamsort.sh > /dev/null 2>&1" >> /etc/crontab
    Careful: be sure it says " >> /etc/crontab" as this will append the cron job at the end of the crontab file. If there is just a single > it will overwrite the whole crontab file.
    You can also edit your crontab file manually with your favorite command line editor by putting
        0 * * * * root ~root/spamsort.sh > /dev/null 2>&1
    at the end of that file.
  11. All done. The script now executes every hour and scans your spamcatcher mailbox for new messages to re-distribute them.
    It wasn't all that hard, was it?

Make sure to read the rest of this page as well and if the spamsort system is working for you, please support the development by donating something... :-)


Files and Folders being used

Here's a list of files and folders that are being used by the script. This information is provided just for your information, so you know what is going where.


History

Current version: 0.1 - updated 29th January 2004


Please support the development of these scripts through PayPal. Thank you.


Copyright by Jochen "Joe" Savelberg - © 2003-2004 -- Last Modified: 29th January 2004