---
name: receive_emails
description: "Fetch unread emails via Gmail IMAP. Requires GMAIL_ADDRESS and GMAIL_APP_PASSWORD environment variables."
---

Fetch unread (UNSEEN) emails from Gmail via IMAP4_SSL. Returns up to max_results emails with sender, subject, date, and body text.

Body extraction prefers plain text; falls back to HTML with tags stripped. Body truncated to 4000 chars.

Each email includes an `id` field (IMAP UID) that can be passed to `mark_email_read` to prevent it appearing in future calls.

Setup: Same credentials as send_email — GMAIL_ADDRESS and GMAIL_APP_PASSWORD in your .env file. IMAP must be enabled in Gmail settings (Settings > Forwarding and POP/IMAP > Enable IMAP).
