Skip to content
OBLAIDISH NEWS
E2e test mailgun email workflows with playwright
TX_899296Engineering

E2e test mailgun email workflows with playwright

Combine Mailgun's live domain with ZeroDrop's disposable inbox to run automated email verification tests in Playwright on GitHub Actions, as shown in a step-by-step guide published on DevTo [DevTo].

sources[DevTo]

Mailgun's sandbox domain cannot be used for automated end-to-end (E2E) verification in CI. A guide on DevTo [DevTo] demonstrates a workflow that swaps the sandbox for a live Mailgun domain and routes each test email to a disposable inbox generated by ZeroDrop. This allows Playwright to assert on subject lines, magic links, and OTP codes without manual inspection.

The author ships a minimal Next.js API route that calls mailgun.client() with the API key and domain, then sends a verification message. In CI, the route uses the live domain (process.env.MAILGUN_DOMAIN) so Mailgun delivers to a real address. ZeroDrop's npm package (zerodrop-client) provides two key functions: generateInbox() creates a unique address, and waitForLatest(inbox, {timeout}) polls the ZeroDrop service until the email arrives, returning a parsed object with subject, magicLink, and otp fields [DevTo].

A Playwright test imports these helpers, signs up a user, waits for the email, extracts the verification link, and completes the flow. The CI workflow file (.github/workflows/e2e.yml) installs Node 20, pulls the repository, runs npm ci, installs Playwright with Chromium, generates an inbox via the zerodrop-dev/create-inbox@8706a59 action, and finally executes npx playwright test with the inbox address injected as TEST_INBOX. All secrets – Mailgun API key, domain, and staging URL – are passed from GitHub Secrets, keeping credentials out of the repo [DevTo].

Using the live Mailgun domain with ZeroDrop's disposable inbox provides several benefits. It validates the full delivery path, including DNS, SPF/DKIM, and spam filtering, which sandbox-only tests miss. This reduces false-positive test passes that occur when developers mock the API. Additionally, ZeroDrop generates a fresh address per job, allowing dozens of concurrent builds to each receive their own email without inbox collisions. The test also confirms that variable substitution renders correctly, catching template-breakage before it reaches users.

operator_channel
[ comments_offline · provider_not_configured ]
transmission_log

Subscribe to the broadcast.

Daily digest of the day's most important tech news. No fluff. Engineering signal only.

// delivered via substack · double-opt-in confirmation