Whitelist via your KAddressBook

22 03 2004

Today SpamAssassin marked a mail sent by a friend of mine as spam. That was the first false positive for… umm… ages. But it still was unnecessary, because I know her and have her in my addressbook. But my Bayes database didn’t know her because she writes me a mail once in a blue moon. And neither was she in my whitelist because I’m too lazy to keep the list in sync with my addressbook.

But OTOH is my addressbook (managed by KAddressBook) relatively up to date. Alas! KMail 3.2 doesn’t support a filter criteria like “sender is in addressbook”.

I first tried to wrote somthing like this via DCOP but that didn’t work because the DCOP interfaces of the apps involved are still far from perfect. So I needed to parse the stuff myself. (Which wasn’t that hard.)

When I later went to file a wish for the new filter criteria, I found out that I obviously wasn’t the first one who needed a script like this. In the existing wish there was a script by J�rg Brenninkmeyer which had the nifty feature to request the list of addresses you recently wrote to, too. I blatantly stole that feature from him ;-)

To cut a long story short, here is my script. To install it, follow the description in the script itself:

This script will read a mail from stdin and query both your KMail list of recent recipients and your KAddressbook for any addresses found in From and Reply-To headers. If an entry was found, a header X-Kmail-Known-Sender with a value of YES or NO is added.

To use this script with KMail, copy this file to ~/bin/kmail-known-sender.sh and create a new filter like this (stuff inside double quotes has to be typed to/chosen from the input fields):

Filter Criteria:
“” “is greater than” “0″
Filter Action:
“pipe through” “~/bin/kmail-known-sender.sh”

Important: Deselect the “If this filter matches, stop processing here”-checkbox.

Now you can check for the X-KMail-Known-Sender where you need it, eg. in a following rule for SpamAssassin:

Filter Criteria:
“X-KMail-Known-Sender” “doesn’t contain” “YES”
Filter Action:
“pipe through” “spamc”

Actions

Informations

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>