Skip to main content

Install

Zero dependencies — stdlib only. Go 1.21+.

Quick start

go test

SSE and polling

WaitForLatest uses Server-Sent Events by default with automatic polling fallback:

Filtering

All string filters are case-insensitive partial matches.

Parallel tests

GenerateInbox runs locally — safe with t.Parallel(), zero collisions:

Free API key (private inboxes)

Without a key, anyone who knows an inbox’s name can read it, and one sender can reach only 5 different inboxes a day: past that, the inbox gets a notice from notice@zerodrop.dev instead of the email. Sign in with GitHub at zerodrop.dev/keys for a free key and set it as ZERODROP_API_KEY. With zerodrop-go v0.2.0 or later, zerodrop.New() reads it, GenerateInbox starts names with your key’s prefix, only your key can read those inboxes, and mail to them isn’t limited:

Error handling

Since v0.2.0 the 401 error wraps ErrUnauthorized with the server’s reason, so compare with errors.Is, not ==. ErrHeld is new in v0.3.0. Without an API key, one sender can reach only 5 different inboxes a day; past that, the email isn’t stored and the inbox gets a notice instead. WaitForLatest then returns an error matching ErrHeld at once rather than waiting for the timeout, and FetchLatest returns it when nothing matches. Older versions treat the notice as an email: without a filter they return it, and a filter such as HasOTP skips it, so the wait times out. A free key from zerodrop.dev/keys lifts the limit for inboxes under your key’s prefix.

Workspaces & self-hosting

A Workspace receives mail on a domain of its own, such as yourcompany-qa.com, and every inbox on it can be read only with your key. Set the domain as ZERODROP_DOMAIN, or pass zerodrop.WithDomain (v0.4.0 or later), next to your key:
Any address on the domain works, including one you name yourself: client.WaitForLatest(ctx, "qa@yourcompany-qa.com", nil) reads the inbox k7x2-qa. client.Domain() returns the domain in use, and a value that isn’t a domain name makes every read return an error matching zerodrop.ErrInvalidDomain. Use the domain as your API keys page shows it. See Workspaces for how mail on it is filed. A self-hosted instance takes its own base URL: