Mailsmith - Whitelist Recipients

Summary: Adds the recipients of the current message to SpamSieve’s whitelist.
Requires: SpamSieve, Mailsmith
Install Location: Mailsmith Support/Scripts/
Last Modified: 2019-10-02

Description

Create a filter in Mailsmith that applies to all messages (Sent Is Equal To True) and runs this script. Attach it to the (outgoing mail) mailbox. Then, each time you send a message, it will add the recipients to SpamSieve’s whitelist.

Installation Instructions · Download in Compiled Format · Download in Text Format

Script

on doAction(mList)
    
tell application "Mailsmith"
        
set theAddresses to {}
        
repeat with m in mList
            
repeat with r in m's to_recipients
                
copy r's address string to end of theAddresses
            
end repeat
            
repeat with r in m's cc_recipients
                
copy r's address string to end of theAddresses
            
end repeat
            
repeat with r in m's bcc_recipients
                
copy r's address string to end of theAddresses
            
end repeat
        
end repeat
        
        
tell application "SpamSieve"
            
tell whitelist
                
add sender rules for addresses theAddresses
            
end tell
        
end tell
    
end tell
end doAction

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 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