bulk_delete_by_sender
Delete all emails from a specific sender in your iCloud Mail inbox. Use this tool to remove unwanted messages and maintain inbox organization through bulk operations.
Instructions
Delete all emails from a specific sender
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sender | Yes | Sender email address | |
| mailbox | No | Mailbox (default INBOX) |
Implementation Reference
- lib/imap.js:851-865 (handler)The bulk_delete_by_sender function retrieves all emails from a specific sender, chunks them, and deletes them from the mailbox.
export async function bulkDeleteBySender(sender, mailbox = 'INBOX', creds = null) { const client = createRateLimitedClient(creds); await client.connect(); await client.mailboxOpen(mailbox); const uids = (await client.search({ from: sender }, { uid: true })) ?? []; if (uids.length === 0) { await client.logout(); return { deleted: 0 }; } let deleted = 0; for (let i = 0; i < uids.length; i += CHUNK_SIZE) { const chunk = uids.slice(i, i + CHUNK_SIZE); await client.messageDelete(chunk, { uid: true }); deleted += chunk.length; } await client.logout(); return { deleted, sender }; }