Warning: Programming/Technical Content
I’m currently using Novell Evolution 1.5.9 as an Outlook replacement, using it for my Calendar, Contacts, and e-mail. I’m also using SpamAssassin 2.63 (specifically, spamc/spamd) for e-mail filtering. What I used to do under Windows was have Outlook check all e-mail against my Contacts and throw away any messages that weren’t explicitly from those people. However, Evolution lacks any method of doing this. As such, I decided to write my own scripts that would allow me to do the exact same thing with SpamAssassin’s user preferences file. The result is quite nice. It goes through all of Evolution’s addressboook.db files (stored for me under ~/.evolution/addressbook/local/) and outputs any line containing the word “EMAIL”, then does some text stripping with sed, sorts the addresses, removes any duplicates, and then regenerates my SpamAssassin user_prefs file with the addresses specified for whitelisting.To avoid making everyone incredibly bored, I’ve added more details in the extended entry.
I did, in fact, check the Web before trying this and came up with this Python script, but it was written for the current production version of Evolution. Since the 1.5 branch of Evolution uses a different addressbook layout than the 1.4 branch, I had to start from scratch. Thus, there are actually three scripts, all written in bash:
exportcontacts: This script first uses the fixed path to the Evolution contact files and gets a listing of that directory. Out of this, we get a list of contact directories, which we pass on to a helper script. After calling the helper script on each directory to generate contact lists, it merges all the output files into one file using cat, then sorts the merged file and removes any duplicate addresses through uniq.
filteraddr: This is the helper script used by exportcontacts above. It takes a full file path and a file output path. The script is only three lines:
less -f $1 | grep EMAIL >> ~/output.tmpa sed -e 's/.*EMAIL;TYPE=.*://g' ~/output.tmpa >> ~/$2.tmp rm ~/output.tmpa
It forces the output of the addressbook.db file to a temporary file, uses sed to strip the e-mail information used by Evolution, then creates a new temporary file with whatever name was passed to the script.
whitelist-gen: This script first calls the exportcontacts script, then strips the current SpamAssassin user_prefs file of any whitelist information. After that, it uses the information exported by the exportcontacts script to regenerate the whitelist and save the new user preferences to the correct location.
Overall, this system is probably a little clumsy and could more than likely have been done better, but it seems like it’ll work quite well. It took me a couple hours, but I’m quite proud of it.