Test addresses that do not cause incidents

Test addresses that do not cause incidents

·

Testing anything that sends mail runs into the same question: what address do you put in? The wrong answer produces a class of bug that is embarrassing rather than merely broken — mail from your staging environment arriving at a real person.

First decide whether the mail has to arrive

This single question decides everything, and it is worth asking explicitly because the answer is “no” more often than people assume.

What you are testingDoes mail need to arrive?Use
Validation, storage, display of an addressnoa reserved domain — see below
The confirmation flow, by handyesa mailbox here
The confirmation flow, automatedyes, readable by codea service with an API
Load or volume testingno — and must nota reserved domain, always

When mail must not arrive: use reserved names

Two domains exist precisely for this and are guaranteed never to belong to anyone: example.com and its siblings example.net and example.org, reserved by RFC 2606, plus the whole .test top-level domain.

Addresses at these are the correct answer for fixtures, seed data and load tests. Nothing you send can reach a person, because there is nobody there — by international agreement rather than by luck.

⚠️
Do not invent domains that look plausible.test@mycompanytest.com is somebody's real domain often enough to matter, and a load test aimed at it is indistinguishable from an attack. The reserved names cost nothing and remove the entire category of accident.

When mail must arrive, by hand

Take an address here, run the flow, read what your application actually sent — headers, links, and how the message renders when it is not your own mail client displaying it. Two things this catches that a local mail catcher does not:

Watch the attachment warnings too, if your application sends files: they are the same warnings your users will see.

When it must be automated

ℹ️
There is no public API here. Mailboxes are read through the page, and nothing is offered for scripts to poll. Said plainly so nobody spends an afternoon looking for it: for automated tests that must read a message, use a service built for that, with an account and a key.

Scraping the page instead is a bad trade even when it works: it is brittle, undocumented, and it is exactly the traffic pattern that eventually gets blocked.

Testing rejection paths

The interesting failures are not “a valid address works”. Worth covering:

One thing to build, not to test

If your product refuses disposable addresses, refuse them clearly. “Invalid email” for a perfectly valid address is the single most confusing error in the category: the user checks the spelling, retypes it, and gets the same message. “We do not accept temporary addresses” takes the same space and ends the confusion.

सभी लेख