Mailsmith - Label By Score
Summary: Labels spam messages according to their spamminess.
Requires: SpamSieve, Mailsmith
Install Location: Mailsmith Support/Action Scripts/
Last Modified: 2019-10-02
Description
You can use this script instead of Mailsmith’s built-in support for SpamSieve, if you want additional flexibility. First, uncheck Use SpamSieve in the Spam Handling preferences. Then create a filter that runs this script on every message. Very spammy messages will be colored tan (custom label 20), less spammy ones will be colored brown (custom label 19), and good messages will be left unlabeled.
Installation Instructions · Download in Compiled Format · Download in Text Format
Script
property possibleSpamLabelIndex : 26
property spamLabelIndex : 27
property threshold : 90
on run
set theList to getList()
if theList is not {} then
my doAction(theList)
else
display dialog "No messages were selected" buttons "OK"
end if
end run
on filtermessage(m)
my doAction({m})
end filtermessage
on doAction(mList)
tell application "Mailsmith"
repeat with m in mList
try
set s to m's RFC822 message
tell application "SpamSieve"
set theScore to score message s
end tell
if theScore ≥ 50 then
set m's is_spam to true
set m's is_not_spam to false
if theScore > threshold then
set label index of m to spamLabelIndex
else
set label index of m to possibleSpamLabelIndex
end if
else
set m's is_not_spam to true
set m's is_spam to false
end if
end try
end repeat
end tell
end doAction
on getList()
tell application "Mailsmith"
set retry to false
try
set mList to get selection as list
set m to item 1 of mList
if class of m is not message then set retry to true
on error
set retry to true
end try
if retry then
set retry to false
try
set mList to message of window 1 as list
on error
set retry to true
end try
end if
if retry then set mList to {}
end tell
return mList
end getList