| Sync ProcMail (AppleScript) |
Friday, May 20, 2005 |
|
(* This is script loops through every email address in my address book and every email address in any .vcf files I have put in ~/Documents/Removed vCards/ , creates a procmail recipie file , and then ftp's it up to my server. *) property m_username : "XXXXXXXX" property m_password : "XXXXXXXX" on run dreamhost() end run on addaddress(e) set nl to ASCII character 10 set s to "" set s to s & ":0:" & nl as string set s to s & "* ^From:.*" & e & nl as string set s to s & "$MBOX/" & nl & nl as string return s end addaddress on addaddress_df(e) set nl to ASCII character 10 set s to "" set s to s & ":0" & nl as string set s to s & "* ^From.*" & e & nl as string set s to s & "! $EMAILADR" & nl & nl as string return s end addaddress_df on extractemailfromvcard(f) set fp to open for access f set s to read fp close access fp set reggex to "[a-zA-Z0-9_-]*@[a-zA-Z0-9_-]*\\.?[a-zA-Z0-9_-]*\\.[a-zA-Z0-9_-]*" try set e to find text reggex in s with regexp on error return "" end try return matchResult of e end extractemailfromvcard on dreamhost() -- -- add emails from address book -- tell application "Address Book" set emaillist to the value of every email of every person end tell set myemails to {"", " ", " ", "XXXX@panix.com", "XXXX@designframe.com", "XXXX@spahr.org", "XXXX@designframe.com", "XXXX@designweenie.com", "XXXXX@designframe.com"} set nl to ASCII character 10 set str to "" & nl as string repeat with p in emaillist repeat with e in p if myemails does not contain e then set str to str & (addaddress(e)) as string end if end repeat end repeat -- -- add emails from removed vcards -- set docs to path to documents folder as string set fpath to alias (docs & "Removed vCards:" as string) tell application "Finder" set filelist to every file in fpath end tell repeat with f in filelist set e to extractemailfromvcard(f as alias) if myemails does not contain e then set str to str & (addaddress(e)) as string end if end repeat --set str to str & "INCLUDERC=/net/local/filters/rc.spamassassin " & nl as string tell application "Finder" set myLib to folder "Library" of home as string end tell set filepath to myLib & "procmailrc.temp" as string tell application "Finder" if file filepath exists then delete alias filepath end if end tell set fp to open for access file filepath with write permission write str to fp close access fp set cmdline to "curl --upload-file \"" & POSIX path of alias filepath & "\" --user \"XXXXX:XXXXX\" ftp://ftp.spahr.org/.procmail/whitelist.rc" do shell script cmdline tell application "Finder" delete alias filepath end tell end dreamhost |
|
| Top | Made with Script Debugger 3.0 | |