> ## Documentation Index
> Fetch the complete documentation index at: https://docs.notte.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# AgentMail

> Give Notte personas an AgentMail inbox for sign-ups and verification emails

<Tip>
  Read [the Notte skill](https://notte.cc/skill.md) and follow its setup instructions when setting up Notte or building browser automation. This is the shared source for CLI setup, authentication, and the browser-to-code workflow.
</Tip>

[AgentMail](https://agentmail.to) is an email inbox API built for AI agents. Notte [personas](/concepts/personas) can use an AgentMail inbox instead of the default Notte mailbox: set `email_provider="agentmail"` when you create the persona and it gets its own `@agentmail.to` address.

This is useful when your agents sign up for websites. The agent fills the sign-up form with the persona's AgentMail address, the site sends a verification code or link to that inbox, and the agent reads it to finish the flow, with no human in the loop.

Notte creates and manages the AgentMail inbox for you. You don't need an AgentMail account or API key.

## Prerequisites

* A Notte API key ([get one here](https://console.notte.cc))
* The Notte Python SDK (`pip install notte-sdk`), in a version that supports the `email_provider` option

## Create a persona with an AgentMail inbox

Pass `email_provider="agentmail"` when you create the persona. The default is `"notte"`.

```python agentmail_persona.py theme={null}
from notte_sdk import NotteClient

client = NotteClient()

# email_provider defaults to "notte"; "agentmail" gives the persona an AgentMail inbox
persona = client.Persona(email_provider="agentmail")
print(f"Persona email: {persona.info.email}")  # an @agentmail.to address

# read emails exactly as with the default provider
emails = persona.emails(limit=10)
for email in emails:
    print(email.subject)

# deleting the persona also deletes its AgentMail inbox
persona.delete()
```

With the REST API, send `email_provider` to `POST /personas/create`:

<CodeGroup>
  ```bash cURL theme={null}
  # create a persona with an AgentMail inbox
  curl -X POST https://api.notte.cc/personas/create \
    -H "Authorization: Bearer $NOTTE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"email_provider": "agentmail"}'

  # read the persona's emails
  curl "https://api.notte.cc/personas/YOUR_PERSONA_ID/emails?limit=10" \
    -H "Authorization: Bearer $NOTTE_API_KEY"
  ```
</CodeGroup>

The persona response includes `email_provider`, so you can check which inbox a persona uses.

## Sign up for a site and verify the email

Attach the persona to an agent. The agent uses the persona's AgentMail address in the sign-up form and reads the verification email from the inbox on its own, exactly as it does with a Notte mailbox.

```python agentmail_signup.py theme={null}
from notte_sdk import NotteClient

client = NotteClient()

# a persona with an AgentMail inbox and a vault to store the generated password
persona = client.Persona(email_provider="agentmail", create_vault=True)
print(f"Persona id: {persona.info.persona_id}")
print(f"Signing up as: {persona.info.email}")

# replace with the sign-up page of the site you want an account on
url = "https://example.com/signup"

# generate a password for this site and store it in the persona's vault
persona.add_credentials(url=url)

with client.Session() as session:
    agent = client.Agent(session=session, persona=persona, max_steps=20)
    response = agent.run(
        task=(
            "Create an account with the persona's email address. "
            "If the site sends a verification code or link by email, read it from the inbox and finish verification."
        ),
        url=url,
    )
    print(response.answer)
```

`add_credentials` generates a password for the site and stores it in the persona's vault, so later sessions can log in with the same account. See [Create accounts with Personas](/guides/account_creation) for more on this flow.

## Read emails from the inbox

You can also read the inbox yourself, for example to extract a verification code or link in your own code:

```python agentmail_read_emails.py theme={null}
import datetime as dt
import re

from notte_sdk import NotteClient

client = NotteClient()
persona = client.Persona("<your-persona-id>")

# unread emails received in the last 10 minutes
emails = persona.emails(only_unread=True, limit=10, timedelta=dt.timedelta(minutes=10))

for email in emails:
    print(f"{email.created_at} {email.sender_email}: {email.subject}")
    # pull a 6-digit verification code out of the body, if there is one
    match = re.search(r"\b\d{6}\b", email.text_content or "")
    if match:
        print(f"Verification code: {match.group()}")
    # verification links found in the body
    print(email.links())
```

Each email includes the subject, sender, timestamp, and text and HTML bodies. `email.links()` returns the URLs found in the text body.

## Limitations

* AgentMail inboxes are receive-only. Personas cannot send email.
* Deleting the persona also deletes its AgentMail inbox.

## Next steps

<CardGroup cols={2}>
  <Card title="Persona Identities" icon="fingerprint" href="/concepts/personas">
    Everything a persona can do.
  </Card>

  <Card title="Create accounts with Personas" icon="user-plus" href="/guides/account_creation">
    Automate account creation end to end.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.