# How to send and receive emails in automation tests

To receive email in automation tests, Humanless gives each test its own disposable address over REST and a wait call that returns the newest message, with any OTP code and link already parsed out. Your app does the sending as usual, so the test covers your real email path. Humanless only receives; it doesn't send mail. There are three common ways to receive: an inbox API (Humanless, Mailosaur, MailSlurp), IMAP or the Gmail API on a real mailbox, or a local mail catcher such as Mailpit. Pick the one that fits where your tests run.

```bash curl
# 1. create an inbox and keep its id
ID=$(curl -s -X POST https://api.usehumanless.com/v1/identities \
  -H "Authorization: Bearer $HUMANLESS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"channels":["email"]}' | jq -r .identity_id)

# 2. after your test submits the form: block until the email arrives (timeout 0-60 s)
curl "https://api.usehumanless.com/v1/identities/$ID/wait?channel=email&timeout=60" \
  -H "Authorization: Bearer $HUMANLESS_API_KEY"
# -> {"type":"otp","code":"482913","url":null,"channel":"email", ...}   (HTTP 408 = nothing yet, call again)

# 3. clean up
curl -X DELETE https://api.usehumanless.com/v1/identities/$ID -H "Authorization: Bearer $HUMANLESS_API_KEY"
```

## Other options

- **Mailpit**: catches everything your app sends over SMTP and has a REST API to read it. It can also act as the SMTP server your tests send through.
- **IMAP or the Gmail API**: works with any real mailbox; you poll and parse yourself.
- **Mailosaur or MailSlurp**: hosted APIs that can both send and receive test email.

> **Use policy:** Only for apps you own or are authorized to test. See the [Terms](/terms).

More: [How to test email OTP and verification codes](/guides/playwright-email-otp) · [All answers](/answers/)

Last updated 2026-12-04

Canonical: https://usehumanless.com/answers/how-to-send-and-receive-emails-in-automation-tests

---
More: https://usehumanless.com/llms.txt
