PowerMail - Redirect Good Mail

Summary: Moves spam messages to the Spam folder and redirects good messages to another address.
Requires: SpamSieve, PowerMail
Install Location: PowerMail Files/Custom Scripts
Last Modified: 2010-11-27

Description

Create a mail filter that executes this AppleScript, and use it instead of your normal PowerMail spam rule. Then, the spam messages will be put in the Spam folder, and the good messages will be redirected to another account. For instance, you could leave this running on your Mac so that when you check your second mail account from the road—with a PowerBook or handheld—you don’t have to sift through the spam.

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

Script

property redirectAddress : "address@domain.com"
property spamFolderName : "Spam"
property spamlabel : 7
property markSpamMessagesRead : false

tell application "PowerMail"
    
set msgs to current messages
    
repeat with m in msgs
        
try
            
set s to m's source
            
tell application "SpamSieve"
                
set isSpam to (looks like spam message s)
            
end tell
            
if isSpam then
                
if not (exists message container spamFolderName) then
                    
make new message container with properties {name:spamFolderName}
                
end if
                
if markSpamMessagesRead then set status of m to read
                
set label of m to spamlabel
                
move m to message container spamFolderName
            
else
                
set theRedirect to redirect m to {redirectAddress}
                
send theRedirect
                
set status of m to unread
            
end if
        
end try
    
end repeat
end tell