Rules Scripting Sample
Summary: Demonstrates how to control SpamSieve’s rules using AppleScript.
Requires: SpamSieve
Install Location: ~/Library/Scripts/SpamSieve Scripts/
Description
This script demonstrates how to control SpamSieve’s blocklist and whitelist using AppleScript.
The order of the words in the corpus is undefined, so to save a particular word you should remember its string, not its index.
Using get every word (and other operations on very large
numbers of words) will not work, because AppleScript runs out of
memory.
Download in Compiled Format · Download in Text Format
Script
tell application "SpamSieve"
-- Prune unused blocklist rules; this will be very slow if there
-- are lots of rules, so you might want to use a "with timeout" block.
-- It would be faster to do this using the the Blocklist window.
tell blocklist
delete (every rule whose hits is 0)
end tell
-- Look up a rule by its text and enable it
tell whitelist
-- there may be more than one rule with this text
set l to every rule whose text to match is "foo@bar.com"
set r to item 1 of l
set r's isEnabled to true
end tell
-- Makes a new blocklist rule that matches messages with zip
-- attachments.
tell blocklist
make rule with properties {text to match:".zip", match field:any attachment name, match style:ends with style}
end tell
-- Easily make blocklist rules that match the From address.
tell blocklist
add sender rules for addresses {"foo@bar.com", "foo@baz.com"}
end tell
end tellLast Modified: 2010-11-27