OS X Address Book to spamassassin whitelist

You have a good maintained Address Book and want to feed Spamassassin’s whitelist from it ? Here is the trick :

cd ~/Library/Application\ Support/AddressBook
sqlite3 AddressBook-v22.abcddb \
    "select ZADDRESS from ZABCDEMAILADDRESS;" \
    | xargs -n 1 echo "whitelist_from " \
    | sort > ~/tmp/whitelist

Then, edit ~/.spamassassin/user_prefs, and add the content of ~/tmp/whitelist.

Notice : the sort command is purely optional.

Comments 2

  1. Christian wrote:

    You could write the query as

    select “whitelist_from ” || ZADDRESS from ABCDEMAILADDRESS order by 1

    and eliminate the xargs and sort steps. If you create a whitelist every day, this would save 2 seconds of cpu time in the next seven years :)

    Posted 02 Nov 2008 at 19:15
  2. sailor wrote:

    Good idea, it needs some escaping but produce the desired result directly :

    cd ~/Library/Application\ Support/AddressBook
    sqlite3 AddressBook-v22.abcddb \
    "select \"whitelist_from \" || ZADDRESS from ZABCDEMAILADDRESS order by 1" > ~/tmp/whitelist

    Posted 02 Nov 2008 at 20:14

Post a Comment

Your email is never published nor shared. Required fields are marked *

Powered by WP Hashcash