get_emails_by_sender
Retrieve emails from a specific sender in your iCloud Mail account. Filter messages by sender address or domain, specify mailbox, and set result limits.
Instructions
Get all emails from a specific sender
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sender | Yes | Sender email address or domain | |
| mailbox | No | Mailbox to search (default INBOX) | |
| limit | No | Max results to show (default 10) |
Implementation Reference
- lib/imap.js:826-849 (handler)Implementation of get_emails_by_sender tool, which connects to IMAP, searches for emails from a sender, fetches details for recent ones, and returns them.
export async function getEmailsBySender(sender, mailbox = 'INBOX', limit = 10, creds = null) { const client = createRateLimitedClient(creds); await client.connect(); await client.mailboxOpen(mailbox); const uids = (await client.search({ from: sender }, { uid: true })) ?? []; const total = uids.length; const recentUids = uids.slice(-limit).reverse(); const emails = []; for (const uid of recentUids) { const msg = await client.fetchOne(uid, { envelope: true, flags: true }, { uid: true }); if (msg) { emails.push({ uid, subject: msg.envelope.subject, from: msg.envelope.from?.[0]?.address, date: msg.envelope.date, flagged: msg.flags.has('\\Flagged'), seen: msg.flags.has('\\Seen') }); } } await client.logout(); return { total, showing: emails.length, emails }; }