Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOW-TO: filter your abook-addresses w/ procmail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
pi-cubic
Tux's lil' helper
Tux's lil' helper


Joined: 25 May 2003
Posts: 143

PostPosted: Sun Nov 30, 2003 7:38 pm    Post subject: HOW-TO: filter your abook-addresses w/ procmail Reply with quote

hi,

have you ever wanted to filter your abook-contacts with procmail into a special folder? here the solution: just edit your .procmailrc!

your .procmailrc
Code:
ABOOK=`grep ^email= ~/.abook/addressbook | cut -b7- | tr '\n' '|' | sed 's/|$//'`

:0:
* $^From.*(${ABOOK})
$MAILDIR/private



have phun,

pi-cubiq
Back to top
View user's profile Send private message
drb
n00b
n00b


Joined: 16 Dec 2002
Posts: 56
Location: Grand Forks, BC, Canada

PostPosted: Tue Dec 16, 2003 9:36 pm    Post subject: Reply with quote

Would someone be so kind as to rewrite this rule to use Sylpheed's addressbook.

Sylpheed stores its address book in xml formated files in ~/.sypheed.

I have no clue as to how to even start.

Thanks in advance!
_________________
Darrell Bellerive
VA7TO
Back to top
View user's profile Send private message
pi-cubic
Tux's lil' helper
Tux's lil' helper


Joined: 25 May 2003
Posts: 143

PostPosted: Tue Dec 16, 2003 9:42 pm    Post subject: Reply with quote

the only clue here is to use regular expressions. i don't know how the sylpheed-adress-book-file is designed. please post an example, maybe i can help you!
Back to top
View user's profile Send private message
drb
n00b
n00b


Joined: 16 Dec 2002
Posts: 56
Location: Grand Forks, BC, Canada

PostPosted: Tue Dec 16, 2003 10:27 pm    Post subject: Reply with quote

There is an index file: ~/.sylpheed/addrbook--index.xml which contains:
<?xml version="1.0" encoding="US-ASCII" ?>
<addressbook>
<book_list>
<book name="Personal address" file="addrbook-000002.xml" />
</book_list>
<vcard_list>
</vcard_list>
<jpilot_list>
</jpilot_list>
<ldap_list>
</ldap_list>
</addressbook>

The book name points to the address book files, of which there could be as many as the user creates.

The addressbook file contains:
<?xml version="1.0" encoding="US-ASCII" ?>
<address-book name="Personal address" >
<person uid="73604869" first-name="Barb" last-name="SampleA" nick-name="" cn="Barb SampleA" >
<address-list>
<address uid="73604870" alias="" email="bsamplea@domain1.fake" remarks="" />
</address-list>
<attribute-list>
</attribute-list>
</person>
<person uid="73604860" first-name="Darrell" last-name="SampleB" nick-name="" cn="Darrell SampleB" >
<address-list>
<address uid="73604861" alias="" email="dsampleb@domain2.fake" remarks="" />
</address-list>
<attribute-list>
</attribute-list>
</person>
<person uid="73604862" first-name="Henry" last-name="SampleC" nick-name="" cn="Henry SampleC" >
<address-list>
<address uid="73604863" alias="" email="henrys@domain3.fake" remarks="" />
</address-list>
<attribute-list>
</attribute-list>
</person>
<person uid="73604864" first-name="Bernd" last-name="SampleD" nick-name="" cn="Bernd SampleD" >
<address-list>
<address uid="73604866" alias="" email="Bernd.SampleD@domain4.fake" remarks="Work" />
<address uid="73604867" alias="" email="b.sampled@domain5.fake" remarks="Home" />
<address uid="73604868" alias="" email="bernd.sampled@domain6.fake" remarks="Home" />
</address-list>
<attribute-list>
</attribute-list>
</person>
</address-book>

Each person can have multiple email addresses.
All the information is there, I just have no clue as to how to use regular expressions.
_________________
Darrell Bellerive
VA7TO
Back to top
View user's profile Send private message
pi-cubic
Tux's lil' helper
Tux's lil' helper


Joined: 25 May 2003
Posts: 143

PostPosted: Tue Dec 16, 2003 10:55 pm    Post subject: Reply with quote

Code:
grep email <sylpheed-adress-book-file> | sed 's/.*email="//' | sed 's/".*//' | tr '\n' '|' | sed 's/|$//'

(sure, there are more elegant versions of doing this, but this one does its purpose)

i think this filters your emails to the following output:
Code:
bsamplea@domain1.fake|dsampleb@domain2.fake|henrys@domain3.fake|  \n
Bernd.SampleD@domain4.fake|b.sampled@domain5.fake|bernd.sampled@domain6.fake


the rest should be done as above.
Back to top
View user's profile Send private message
drb
n00b
n00b


Joined: 16 Dec 2002
Posts: 56
Location: Grand Forks, BC, Canada

PostPosted: Tue Dec 16, 2003 11:38 pm    Post subject: Reply with quote

Thanks very much!

So I am correct with this recipe:
Code:

ABOOK=`grep email ~\.sylpheed\addrbook-000002.xml | sed 's/.*email="//' | sed 's/".*//' | tr '\n' '|' | sed 's/|$//'`

:0:
* $^From.*(${ABOOK})
$MAILDIR/private


Or this recipe:
Code:

ABOOK=`grep ^email= ~\.sylpheed\addrbook-000002.xml | sed 's/.*email="//' | sed 's/".*//' | tr '\n' '|' | sed 's/|$//'`

:0:
* $^From.*(${ABOOK})
$MAILDIR/private

_________________
Darrell Bellerive
VA7TO
Back to top
View user's profile Send private message
pi-cubic
Tux's lil' helper
Tux's lil' helper


Joined: 25 May 2003
Posts: 143

PostPosted: Wed Dec 17, 2003 12:04 am    Post subject: Reply with quote

your correct with the first recipe: the second one would search for an expressoin email at the beginning of the line (this is the "^") which is not the case.

good luck :)
Back to top
View user's profile Send private message
drb
n00b
n00b


Joined: 16 Dec 2002
Posts: 56
Location: Grand Forks, BC, Canada

PostPosted: Fri Dec 19, 2003 7:55 am    Post subject: Reply with quote

Thanks very much pi-cubiq!

It is working.
_________________
Darrell Bellerive
VA7TO
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum