Skip to content

feat: add Email and Microsoft 365 Mail tools for agents to search, read, sort, send and reply, and open attachments with the user's consent - #1035

Merged
croffasia merged 2 commits into
mainfrom
feat/agent-tool-email
Nov 29, 2026
Merged

croffasia merged 2 commits into
mainfrom
feat/agent-tool-email

Conversation

@croffasia

Copy link
Copy Markdown
Owner

What

Two new agent tool integrations built from one folder: Email (any mailbox, IMAP and SMTP with a password) and Microsoft 365 Mail (signs in as an Entra ID app registration, the same kind the instance uses for its own mail). Each gives agents 8 tools: list folders, search, read a message, open an attachment, mark, move, send and reply in the same thread.

Why

Agents could not work with mail. With these tools an agent can read and answer a mailbox, and open an attachment once the user agrees.

  • Attachments: a catalog tool can now hand back a file, and the api opens it as it opens an issue attachment: an image reaches the model as the image, a PDF, text or table file as its content, in runs and over MCP. The tool description tells the agent to ask the user before every attachment.
  • Email without an SMTP server only reads. After sending, a copy goes to Sent with its Bcc header (Gmail and Microsoft 365 do this themselves).
  • Mail servers a person enters go through the SSRF guard (resolvePublicHost in @repo/net), TLS is checked against the hostname, and STARTTLS is required on other ports. A malformed or unknown server is rejected on save; one on a private network is left to SSRF_ALLOWED_HOSTS.
  • Changing the server, the mailbox or the tenant of a stored credential requires the password or secret again, so whoever may edit a credential but not read it cannot send the secret elsewhere.
  • The god-mode attachment size limit now also bounds a file a tool hands back and the unpacked size of .xlsx and .docx files before they are parsed (uploads and imports too). Its hint says so in every language.
  • A credential field can carry a group: the form shows it in a collapsible section. Email puts its SMTP fields under Sending. The section component moved from the agent form to TeamFormSection.
  • An emptied plain field in the credential form now clears its stored value.

How to test

  1. Team settings › Integrations › add Email: address, app password, IMAP server (for example imap.gmail.com), and under Sending the SMTP server. Wrong password or imap.gmail.com:993 as the server: saving is refused.
  2. Add the Email tools to an agent and ask it to find a message, read it, open its attachment (it asks first), mark it, and send or reply to yourself.
  3. Edit the credential, empty the SMTP server and enter the password again: the agent then only reads, and sending tells it so.
  4. Microsoft 365 Mail: an app registration with IMAP.AccessAsApp and SMTP.SendAsApp, its service principal given FullAccess to the mailbox, SMTP AUTH on for it. The Tenant ID help lists the steps.

Checklist

  • bun run typecheck passes
  • bun run lint and bun run format:check pass
  • Developed with an AI agent: tidy, code-review and security-audit from .agents/skills/ ran on the new code
  • Tests added or updated for the changed behaviour
  • Database schema changed: migration generated with bun run db:generate and committed
  • New environment variables documented in .env.example
  • Docs updated (README.md or docs/). AGENTS.md changed only as docs/dev/agents-md.md allows

Screenshots

None yet.

…ad, sort, send and reply, and open attachments with the user's consent
…d of stripping tags with regular expressions
@croffasia
croffasia merged commit bd16bc4 into main Nov 29, 2026
7 checks passed
@croffasia
croffasia deleted the feat/agent-tool-email branch November 29, 2026 01:34
@github-actions github-actions Bot mentioned this pull request Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants