On Mon, 2003-03-24 at 12:51, Cliff Wells wrote:

> Here's a Python script I hacked up a a few minutes ago.
> 
> exportcontacts.py > whitelist
> 
> will give you a list of all the email addresses in your Evo contacts
> database.

Okay, here's a modified version that can be used one of two ways, either
as a way to dump the email addresses from the Evo contact database, or
as a filter.

1. Dump email addresses:
     whitelist.py > whitelist.txt

2. As a filter:
     whitelist.py [EMAIL PROTECTED]  
     returns 0 if not in contacts or non-zero if [EMAIL PROTECTED] is 
     in contacts.  You can plug this into Evo's filter system.  I'd
     add it as the second to last filter, just before spamassassin with
     a "Stop Processing" directive if whitelist.py returns non-zero.


Regards,

-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308
#!/usr/bin/python


import bsddb, os, re, sys

if len(sys.argv) > 1: # return 0 or 1 if arg is in contacts
    check = sys.argv[1]
else:
    check = None      # just dump a list of contacts
    
home = os.getenv('HOME')
dbname = '%s/evolution/local/Contacts/addressbook.db' % home

db = bsddb.hashopen(dbname, 'r')

regex = re.compile('EMAIL;INTERNET:(?P<contact>.*)[\n|$]', re.M)

for k in db.keys():
    mo = regex.search(db[k])
    if mo:
        contact = mo.group('contact').strip()
        if contact:
            if check is not None:
                if check == contact:
                    db.close()
                    sys.exit(1)
            else:
                print contact
        
db.close()

Reply via email to