Plugin for KMail to Report Spam Messages from Debian MLs

This page describes how KMail filters can be used to report spam on a Debian mailing list.

KMail 1.9.9 from KDE 3.5

Below are two possible solutions. The first is slightly more complex, but is preferred as it better fulfills the requirements listed by the list masters. It also looks as if the second method does not work if your mail folders are on an IMAP server.

Both methods have been developed and tested on system running Debian Lenny running KDE 3.5. Possibly they can also be (adapted to be) used with KDE 4.0, but that has not been tested.

Using the HTTP API to report spam

For this method the following packages should be installed:

First save the following procmail recipe, for example in ~/bin/dl-reportspam:

# Procmail recipe that reports a post to a Debian mailing list as spam
# Intended to be run from a KMail filer (KMail 1.9.9 from KDE 3.5)

# Uncomment next lines for debugging
#LOGFILE=$HOME/dl-reportspam.log
#VERBOSE=on

# Is this a Debian list mail?
:0
* List-Id: <[^ ]+\.lists\.debian\.org>
{
    # Use '?' to return with exit code of POST command
    # Match on Message Id (gets assigned to $MATCH)
    :0 W
    * ^Message-Id: \/.*
    | /usr/bin/GET "http://lists.debian.org/cgi-bin/nominate-for-review.pl?Quiet=on&msgid=$MATCH"
}

# Fail if not a Debian list mail
EXITCODE=1

# Make sure the mail is ignored if we fall through
:0
/dev/null

Next create a filter using the 'Settings -> Configure Filters...' menu option which will display the 'Filter Rules' dialog:

To use the filter, simply press the shortcut key you defined while the mail you want to report as spam is "active".

/!\ The filter will move the mail to the trash folder even if submitting it as spam fails.

The filter can be adjusted to your personal taste, but please make very sure that only mails that really are spam are reported. I.e, make sure it is never used for automatic filtering.

Debugging in case of problems:

Report spam by bouncing the mail

Disadvantage of this alternative method is that it does not provide any feedback on whether the mail was successfully reported as spam or not. It may also not work if your mail folders are on an IMAP server; the filtering on List-Id does not seem to work in that case.

Create a filter using the 'Settings -> Configure Filters...' menu option which will display the 'Filter Rules' dialog:

After you apply the filter to a mail, the bounced mail will sit in your outbox until the next delivery is made. This should happen automatically when you send a normal mail.

Tip: if your ISP does not allow you to bounce messages (yes, unfortunately such braindead ISPs exist), adding an extra filter action that removes "Received" headers may help.