Jun 04, '04 11:00:01AM • Contributed by: Phoenix1701
A better (and more consistent) way would be to actually mark these messages as Junk Mail when they arrive. Mail's rules have no "Mark as Junk" option, which is rather silly, but as usual this can be done using the wonders of AppleScript. When Mail executes an AppleScript as the result of a rule action, it looks for a perform mail action with messages handler in the script it's running. If it finds one, it will populate the messages argument with the list of messages matching the rule and the rule argument with the rule that's running the script. Therefore, we can tell Mail to mark all messages matching the rule as junk mail using the following script:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theMessages
set junk mail status of eachMessage to true
end repeat
end tell
end perform mail action with messages
end using terms from
Simply save this script into ~/Library -> Scripts -> Mail Scripts (or wherever you'd prefer to keep it; putting it in the Mail Scripts folder just allows you to call the script on a set of selected messages as well), and then add a rule action "Run AppleScript" to the rule from which you wish to invoke it. Select the script, and you're done. From now on, junk mail will be flagged as such whenever it is encountered, and Mail's built-in spam filtering will pay attention.
[robg adds: I recall reading that, as long as (a) the messages go into the official Junk mail folder and (b) you use the contextual menu to delete the Junk messages, then Mail's filter would scan and learn from those messages, regardless of how they got there. If someone knows the official answer, please post a comment...]
