How can I permanently delete emails from the Junk folder?

I have this Apple Script that I use to get rid of emails in my Junk folder that are over two days old. The problem is that it moves them to Trash and I want to actually delete them. Is that possible?


tell application "Mail"


set theAccount to account "Google"


set theMailbox to mailbox "Junk" of theAccount


set theMessages to messages of theMailbox



repeat with eachMessage in theMessages


set messageDate to date received of eachMessage


set currentDate to (current date)


set dateDifference to (currentDate - messageDate) / days



if dateDifference > 2 then


delete eachMessage


end if


end repeat


end tell



[Re-Titled by Moderator]

iMac 24″

Posted on Mar 4, 2025 9:52 AM

Reply
3 replies
Sort By: 

Mar 4, 2025 1:08 PM in response to xWauwau

Thanks, but iI don't want to delete all Trash that's more than 2 days old, and I don't want junky mail getting into any place where it might be seen by someone besides me who might happen to be using my mac, so I'm looking for a script modification that won't put junky stuff in Trash in the first place.

Reply

Mar 4, 2025 1:24 PM in response to MartinLiss

Oh, I see. So, as far as I know, unfortunately, Gmail will put deleted emails always into the trash bin. Note that I’ve just spent 5 mins researching and that this is not a definite statement whatsoever. Yet, feel free to give updates to your solution as they might help other members in our community. Thank you!

Reply

How can I permanently delete emails from the Junk folder?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.