Manage Trash
manage_trashPreview and move emails to Trash, or attempt to empty Apple Mail's trash with dry-run safety checks.
Instructions
Manage trash operations - delete emails or empty trash.
When dry_run=True (default) and action is "move_to_trash", previews what would be deleted without acting. Set dry_run=False to actually move to trash.
Mail's AppleScript interface has no command that erases a message: delete
means "move to Trash", and on a message that already sits in Trash it does
nothing. "delete_permanent" and "empty_trash" therefore usually remove
nothing at all. Both report the real before/after mailbox count instead of
the number of delete calls, and say so when nothing was removed; emptying
the trash for good has to happen in Mail itself.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform: "move_to_trash", "delete_permanent", "empty_trash" | |
| sender | No | Optional sender to filter emails (not used for empty_trash) | |
| account | Yes | Account name (e.g., "Gmail", "Work") | |
| dry_run | No | If True (default), preview what would be affected without acting | |
| mailbox | No | Source mailbox (default: "INBOX", not used for empty_trash or delete_permanent) | INBOX |
| max_deletes | No | Maximum number of emails to delete (safety limit, default: 5) | |
| apply_to_all | No | Must be True to allow operations without subject_keyword or sender filter | |
| confirm_empty | No | Must be True to execute "empty_trash" action (safety confirmation) | |
| older_than_days | No | Optional age filter - only affect emails older than N days | |
| subject_keyword | No | Optional keyword to filter emails (not used for empty_trash) | |
| subject_keywords | No | Optional list of subject keywords; matches any keyword |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |