Mail cleanup rules
A cleanup rule acts on mail older than an age you choose, every hour. For example: empty Trash after 30 days, delete Junk after a week, or move the Inbox's mail older than two years to Archive.
What a rule says
| Part | Choices |
|---|---|
| Mail in | Every folder, or one of Inbox, Sent, Drafts, Archive, Junk and Trash. Folders people made themselves count under Every folder only. |
| Older than | A number of hours, days, weeks, months or years, counted from when the message arrived (or was sent or saved). |
| Then | Mark it read, Move it to Archive, Move it to Trash, or Delete it. |
| For | Every mailbox of the tenant, every mailbox on one of its domains, or one mailbox. |
| Leave starred mail alone | On by default: starred (flagged) messages are never touched. |
| Only mail already read | Off by default: when on, unread mail is left. |
A rule never moves mail to the folder it is already in (Trash to Trash). A mailbox with no Archive or Trash folder is skipped by rules that move mail there. Delete it takes the message out of the rule's folders, and deletes it for good once it is in no other folder; it cannot be undone.
Who sets rules
- The tenant's owners, in the tenant manager at
/manage: Mail → Mail cleanup. Admins and members whose role covers mail see the rules but cannot add or change them, since a rule can delete everyone's mail. - The platform's staff, for one tenant or for every tenant. Their rules show as locked by the platform (or platform): the tenant sees them but cannot change, pause or remove them. If you think one is wrong, open a support ticket.
The magnifying glass beside a rule counts what it would change if it ran now, without changing anything. Last run shows when it ran and how many messages it changed. Pause stops a rule without removing it.
Legal holds
A rule that deletes mail skips every mailbox on legal hold, its own or its whole tenant's (see Compliance archiving), until the hold is lifted. Rules that only mark mail read or move it still run. Mail the compliance archive keeps is not affected by any rule.
How much runs at once
Each rule changes up to 50,000 messages an hour, oldest first; the rest follow in the next hours. Mail apps see the changes at once, as if someone had moved or deleted the messages (IMAP, JMAP and webmail).
From the API
GET and POST /v1/tenants/{tenantId}/cleanup-rules, PATCH and DELETE /v1/tenants/{tenantId}/cleanup-rules/{ruleId}, and GET .../cleanup-rules/{ruleId}/preview. A rule is {"folder": "trash", "olderThan": 30, "unit": "days", "action": "delete"}, with optional domain or accountId, name, keepStarred, onlyRead and enabled. Tenant API keys limited to some domains cannot use these. See api/openapi.yaml (Mail cleanup).