Let an AI agent receive verification codes and magic links
An agent that signs up for a service needs an inbox it can wait on. AI Mail MCP gives it a real mailbox, holds until the confirmation email arrives, and pulls out the code or the link.
Connect your agent Try the demo
The flow
- Get an address.
create_mailboxmakes a mailbox for the sign-up, or the agent uses one it already has. - Use it in the form. The agent signs up with that address.
- Wait.
wait_for_messageblocks until a matching message arrives, for up to 60 seconds a call, and returns it in full. Add a condition in plain words, such as "a verification code from GitHub", and a small model decides which new message matches. - Extract.
extract_codereturns the code or the confirmation link, with a confidence and where it was found.
How extraction works
Extraction uses patterns, not a model, so it costs nothing and does not guess. It finds codes of 4 to 8 digits, or short letters-and-digits codes like KQP-7XZ, when a code word is near them (code, OTP, PIN, passcode, verification). It also finds verification, confirmation, magic sign-in and password-reset links. It ignores numbers that look like orders, invoices, card endings, phone numbers, prices and dates.
Staying safe while waiting on strangers' mail
A sign-up email is mail from a sender you do not control, so it is scored for prompt injection like everything else. If a message is flagged, extraction is refused, except for a short message from an authenticated sender whose domain and signature align. A message that has not been scored yet comes back marked as not yet checked. AI Mail's own sign-in links and codes are never readable by agents. How the safety checks work.
Try it
Connect AI Mail to your assistant (https://aimailmcp.com/mcp) and paste:
Send a test email to my sandbox address with the subject "Your code" and the text "Your verification code is 482916". Then wait for it and extract the code.
Frequently asked questions
How long can an agent wait for an email?
wait_for_message waits up to 60 seconds per call, 25 by default. An agent that needs longer calls it again.
Can it find a magic link as well as a code?
Yes. extract_code returns verification codes and also verification, confirmation, magic sign-in and password reset links, each with a confidence and where it was found.
Does it use a model to read the code?
No. Extraction uses patterns, so it costs nothing and ignores numbers that look like orders, prices, dates or phone numbers. Only the optional plain-words condition on wait_for_message uses a small model.
Is it safe to read mail from a site I just signed up with?
Every message is scored for prompt injection. A flagged message has its body withheld and extraction is refused, apart from a short message from an authenticated sender.
More guides
- An email MCP server for AI agents
- Prompt-injection-safe email for AI agents
- AI triage for your support, sales, billing and legal inbox
- Give your AI agent its own email address
- An email connector for Claude
Docs · Privacy · Terms · Data deletion · Pricing · Support · Security · Status