This requires that you are running SquirrelMail 1.4.x or above and Apache 2.2 or higher.

Download the following related files into your squirrelmail plugins folder:

# cd /usr/local/www/squirrelmail/plugins << For FreeBSD (Other systems may vary)


# fetch http://freebsdrocks.net/files/tarballs/spam_buttons-2.3-1.4.0.tar.gz
# fetch http://freebsdrocks.net/files/tarballs/compatibility-2.0.14-1.0.tar.gz

What we want to do now is create 2 email addresses for vpopmail. We want to create one for ham and one for spam reporting. You can do this as follows:


# ~vpopmail/bin/vadduser thisisspam @ domain.com password
# ~vpopmail/bin/vadduser thisisham @ domain.com password

Make sure password in the 2 examples above are not the actual password. Just create random ones if you like.

Now lets unzip them


# tar zxvf spam_buttons-2.3-1.4.0.tar.gz
# tar zxvf compatibility-2.0.14-1.0.tar.gz

Now to configure spam buttons:

# cd spam_buttons
# cp config_example.php config.php
# vi config.php

The first section under General Options is, well, optional. When you get to the section that says // REPORT-BY-EMAIL OPTIONS, this is where you change a few things:


# $is_spam_resend_destination = ' thisisspam@domain.com';
# $is_not_spam_resend_destination = ' thisisham@domain.com';

Verify the following is set:

//$spam_report_email_method = 'bounce';
$spam_report_email_method = 'attachment';
//$is_spam_subject_prefix = 'SPAM';
//$is_not_spam_subject_prefix = 'HAM';

If you are using my freebsdrocks.net setup, make sure to remove the .qmail files and mailfilter from the vpopmail directory like so


# rm ~vpopmail/domains/domain.com/thisisspam/.qmail
# rm ~vpopmail/domains/domain.com/thisisspam/mailfilter
# rm ~vpopmail/domains/domain.com/thisisham/.qmail
# rm ~vpopmail/domains/domain.com/thisisham/mailfilter

Also, In the config.php and you're using my freebsdrocks setup, You can change the 2 following sections in config.php


$sb_report_spam_by_move_to_folder = 'Inbox.Spam';
$sb_report_not_spam_by_move_to_folder = 'Inbox';

You should now exit and save the file. This script successfully reports and process each message.
However, It does not delete the message when it is being reported.

If you are running Squirrelmail 5.x, Skip the following patch section.

Patch SquirrelMail 1.4.x to enable button display on the message list page. The patch should be run from the spam_buttons directory.


# patch -p0 < patches/spam_buttons-squirrelmail-1.4.4.diff

You will now want to enable the plugin by doing the following:


# cd /usr/local/www/squirrelmail/plugins/config
# ./conf.pl

Go to

8. Plugins

Look under Available Plugins: and look for spam_buttons which is usually the last one at the bottom. The number to the left of it is the number you want to type in to enable it. Do that and hit enter and

then you should see it under Installed Plugins. Also enable the Compatibility plugin as well before you continue. Press S and hit enter to save the data and hit Q to quit and hit enter. The squirrelmail plugin is now enabled and functional.

The startup scripts I just put in my bin directory in my ~home drive.


# cd ~user
# mkdir bin
# cd bin
# fetch http://freebsdrocks.net/files/tarballs/autolearn2.tgz
# tar zxvf autolearn2.tgz


Edit spamauto.sh and hamauto.sh and change the sections that say:


DOMAIN="domain.com"
SPAMUSER="thisis*am"
MAILDIR="/home/vpopmail/domains/$DOMAIN/$SPAMUSER/Maildir/new"
SA_LEARN_LOG="/var/log/spamlearn.log"

Now you can put hamauto.sh and spamauto.sh in crontab like so:


0 1,13 * * * ~user/bin/hamauto.sh > /dev/null 2>&1
0 1,13 * * * ~user/bin/spamauto.sh > /dev/null 2>&1

This will tell crontab to run both scripts at 1PM and 1AM every day. Change at your discretion.

When this is completed, Users will now be able to report ham and spam. :-)