Direct answer

How do you create a temporary email programmatically?

Use a private authenticated inbox API rather than scraping a public disposable-email website, and give each automated task its own recipient and lifecycle.

Maintained by Evidence checked Editorial method

Open the quickstart
Direct answer

With mails0, install the official mails-agent package and run mails bootstrap to create a random hosted provisional mailbox and store its scoped credential locally. The official MCP server can bootstrap the same receive-only first-run mailbox automatically when a tool is called. The hosted provisional address expires after 72 hours and cannot send. Use it in the external workflow, wait for the expected current message, retrieve only the required value, and let it expire unless a human approves a permanent claim or the team moves the workflow to a self-hosted domain.

Visual guide

Workflow at a glance

Tie the address to one expected message

  1. 01
    Record the address and trigger time

    Keep them in scoped application or test state.

  2. 02
    Submit the external action once

    Use the address for signup, invitation, reset, or notification.

  3. 03
    Wait with exact filters

    Match the mailbox, current time window, sender context, and message type.

  4. 04
    Assert the outside result

    Confirm the external workflow completed after using the code or link.

Bootstrap

Create the inbox before starting the external flow

The CLI creates a random address and stores the mailbox credential in local tool state. Do not paste the key into a prompt, test fixture, issue, or CI output. For parallel automation, create a separate mailbox for each run or trust boundary.

Create a provisional mailbox
npm install -g mails-agent && mails bootstrap
Use

Tie the address to one expected message

  1. 01

    Record the address and trigger time

    Keep them in scoped application or test state.

  2. 02

    Submit the external action once

    Use the address for signup, invitation, reset, or notification.

  3. 03

    Wait with exact filters

    Match the mailbox, current time window, sender context, and message type.

  4. 04

    Assert the outside result

    Confirm the external workflow completed after using the code or link.

Security

Temporary does not mean public or consequence-free

A short-lived inbox can still receive credentials, recovery links, private files, and malicious instructions. Use authenticated access, avoid personal data when possible, validate links and attachments, and keep message content out of broad logs.

Do not use a public inbox for secrets. A public address with a guessable web URL is a different trust model from a temporary mailbox protected by a scoped credential.

Lifecycle

Let expiry do its job unless continuity is proven

OutcomeNext actionReason
No useful messageLet the mailbox expireAvoid abandoned identities and credentials
One completed taskKeep temporary unless recurrence is expectedFirst value does not require permanence
Recurring approved workflowRequest a permanent claim or self-hostContinuity and ownership now matter
Suspicious behaviorPause and rotate immediatelyContain the affected scope
Evidence

Sources and product scope

Product behavior is verified against the mails0 source and documentation. External comparisons link to official vendor documentation checked on 2026-08-15.

Questions and answers

Related questions

Can an AI agent create the temporary mailbox automatically?

Yes. The official CLI and MCP paths can bootstrap the hosted provisional receive-only mailbox automatically.

Can a temporary mails0 mailbox send email?

No. Hosted provisional mailboxes are receive-only. Sending requires a permanent or self-hosted configuration with separate policy.

Can the 72-hour address become permanent automatically?

No. A permanent hosted claim requires explicit human approval. Self-hosted operators can define their own identity and lifecycle policy.

Start with a bounded inbox

Prove the smallest useful email loop.

Start with one scoped inbox and one expected message. Add durable identity, sending, and operational complexity only when the first loop works.

Open the quickstart