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:
procmail
libwww-perl (for the GET command)
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/nullNext create a filter using the 'Settings -> Configure Filters...' menu option which will display the 'Filter Rules' dialog:
on the General tab:
leave 'Filter Criteria' blank (the procmail recipe includes the necessary filtering)
define the following 'Filter Actions':
'Execute Command' with value
procmail -m ~/bin/dl-reportspam && kdialog --msgbox "Successfully reported as spam" || kdialog --error "Failed to report as spam"
'Mark As' with value 'Read'
'Move Into Folder' with value 'Local Folders/trash'
on the Advanced tab
the option 'Apply this filter to incoming messages' should not be selected
the option 'Apply this filter to sent messages' should not be selected
the option 'Apply this filter on manual filtering' should not be selected
select the option 'If this filter matches, stop processing here'
select the option 'Add this filter to the Apply Filter menu'
define a Shortcut key for the filter (for example Ctrl+Shift+S)
- optionally, add the filter to the toolbar
use the Rename button on the left of the dialog to give the filter a proper name, for example "Report Debian List spam"
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:
use the 'Filter Log Viewer' option from the 'Tools' menu
- uncomment the debug options in the procmail recipe
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:
on the General tab:
define the following under 'Filter Criteria':
select the 'Match all of the following' option
create a filter rule: 'List-Id', 'matches regular expr.', '<[^ ]+\.lists\.debian\.org>'
define the following 'Filter Actions':
'Redirect To' with value 'report-listspam@lists.debian.org'
'Mark As' with value 'Read'
'Move Into Folder' with value 'Local Folders/trash'
on the Advanced tab
- use the same settings as described above for the HTTP API
- rename the filter as described above for the HTTP API
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.
