This tip will be especially useful for anyone using SpamSieve together with Mail. After disabling Mail's Junk Mail Filtering to let SpamSieve do its magic, you can no longer 'Erase Junk Mail' to immediately delete your accumulated spam. Unfortunately, whenever you delete messages from your 'Spam' folder, they get moved to your Trash mailbox. If you're like me, you'd rather just delete this garbage immediately. To do so, select the messages in your Spam folder and choose Edit -> Cut (or just hit Command-X). The net effect is that the messages are deleted immediately. Enjoy your spam-free Trash! (This has only been verified using Mail 1.3.4 under 10.3.3.)

Is there an Applescript or something to get rid of the garbage from the spam folder? I hate getting my spam folder built up and having to manually delete the messages in there. Also I can't get mail to delete the messages on the server after I get them even though I have it set to to delete them in the advanced section of mail.

The feature "Remove messages from server..." has been broken for me on all releases of Panther. Numerous feedbacks to Apple haven't seemed to help. This worked great in Jaguar, allowing me to keep my local inbox synced with my POP inbox, which is ideal if one travels a lot. My setting is "Remove messages from server: When moved from Inbox" (ie moving a message to the trash folder).

awww, I was hoping for a way to do this for stuff like deleting 2000 messages at once! I let my mailboxes fill up with a lot of cruft and when I want to clear them out I have to delete thousands of messages twice (once from the mailbox, once from the Trash folder). This takes a while. However, cutting will still keep it all in memory. While this is probably better than deleting it twice, it's still not as good as I hoped.

According to Ben Han's JunkMatcher pages you should not have to disable the Mail junk system. Apparently the Mail Junk system is provoked into action when the "Message is junk mail" condition is evaluated. Just move the built in Junk filter up as he has done with his Built-in Junk Filter (step 3, about midway down the page). Then you can set up SpamSieve to use the Junk box with attendant deletion properties. As a bonus, the automatic Mail Junk filter might learn something.

Ben's junkMatcher pages have been interesting reading as he has explored the Mail.app junk system and developed regular expression filtering.

Just a couple days ago, I wrote my very first Applescript just to empty spam mailboxes.

Besides using SpamSieve, I also use SpamAssasin on the server (and IMAP accounts), so all my "Spam" folders quickly get filled up with junk.

My script checks for messages on every "SPAM" mailbox" of every account and deletes them. Then checks for messages on the "Spam" mailbox "In my Mac" and deletes them. Lastly, it empties the Trash by performing the keyboard shortcut (I searched the whole Mail dictionary and couldn't find an "empty trash" command).

I'm sure the code could be greatly improved, so I welcome your suggestions!

try
tell application "Mail"
activate
-- delete messages from spam mailboxes
set theAccounts to every account
repeat with theAccount in theAccounts
if exists messages in mailbox "SPAM" of theAccount then
delete messages of mailbox "SPAM" of theAccount
end if
end repeat
if exists messages in mailbox "Spam" then
delete messages of mailbox "Spam"
end if
end tell
delay 3
-- empty trash for all accounts
tell application "System Events"
tell process "Mail"
set frontmost to true
end tell
keystroke "k" using command down
keystroke return
end tell
end try