
How to Test Email-Change Confirmation Flows
Need a disposable inbox right now?
Spin up a temporary email address in seconds — no signup, no spam, no trace.
Most teams script the signup OTP flow and call email testing done. The email-change flow — the one that fires when a logged-in user updates the address on their account — usually ships untested, because it needs two inboxes instead of one and nobody wants to wire that up by hand.
That gap matters. Email-change is where account-takeover bugs hide: a stale confirmation link that still works after the user changes their mind, a notification that never reaches the old address, a race condition when someone fires the change twice in a row. None of that shows up in a signup test. Here's how to script it properly with disposable inboxes.
Why this flow hides bugs signup tests don't catch
A signup flow has one actor and one inbox: send a code, read the code, done. An email-change flow has one actor and two inboxes, and the correctness of the flow depends on both of them agreeing. Most implementations do one of two things when a user updates their email:
Send a confirmation link to the new address and activate the change only once it's clicked.
Send a notice to the old address at the same time, so an account takeover attempt doesn't happen silently.
Plenty of apps implement the first and skip the second. That's a real gap: if an attacker has a session but not the old inbox, a silent email swap gets them full account recovery later. If your app sends both, your test needs to check both arrived, independently, with the right content in each.
The two-inbox pattern
The fix is the same pattern you'd use for any multi-party email flow: give each side of the exchange its own throwaway address instead of reusing one inbox and hoping the ordering works out.
Treat the "old" and "new" addresses as two separate CyberTemp inboxes for the duration of the test. Trigger the change in your app, then poll both addresses independently. The old address should get a plain notice with no clickable confirmation link. The new address should get the actual confirmation link or code. If your assertion only checks one inbox, you'll never catch the case where the old-address notice silently stops firing after a refactor.
Scripting it against the API
CyberTemp's API reads directly against an address — there's no separate step to provision an inbox first. GET /getMail creates the inbox on first read if it doesn't exist yet, so you can generate both addresses right where the test starts and poll each one as soon as your app fires the request.
import httpx, re, time
API_KEY = "tk_..."
HEADERS = {"X-API-Key": API_KEY}
BASE = "https://api.cybertemp.xyz"
def wait_for_mail(address, timeout=60, interval=3):
deadline = time.time() + timeout
while time.time() < deadline:
r = httpx.get(f"{BASE}/getMail", params={"email": address}, headers=HEADERS)
r.raise_for_status()
messages = r.json()
if messages:
return messages[0]
time.sleep(interval)
raise TimeoutError(f"no mail at {address}")
def extract_confirm_link(body):
match = re.search(r'https://[^\s"<]+/confirm-email[^\s"<]*', body)
return match.group(0) if match else None
old_address = "[email protected]"
new_address = "[email protected]"
# trigger the email-change request in your app here, then:
old_notice = wait_for_mail(old_address)
new_confirm = wait_for_mail(new_address)
assert "didn't request this" in old_notice["body"].lower() or "we noticed" in old_notice["body"].lower()
confirm_url = extract_confirm_link(new_confirm["body"])
assert confirm_url is not None
Run that same assertion against a build where the old-address notice was accidentally dropped and you'll see it fail immediately — which is the whole point. A test that only waits on the new address would pass either way.
Edge cases worth scripting on purpose
Once the happy path works, the interesting bugs are in the states around it. These are cheap to script once you've got two disposable addresses per test run:
Expired or already-used token. Click the confirmation link twice. The second attempt should fail cleanly, not silently re-apply the change or 500.
Change requested twice before confirming. Request a change to address B, then immediately request a change to address C before B confirms. Decide what should win, then assert it actually does.
Revert from the old address. If your product supports a "this wasn't me, revert" link in the old-address notice, test that it actually locks out the pending change rather than just displaying a success page.
Confirmation after the account is deleted. If the account gets deleted between sending the confirmation and the user clicking it, the link shouldn't resurrect a half-updated row.
Each of these is a single extra inbox and a few extra lines of polling — not a new test harness.
Wiring it into CI
Because addresses are just strings and inboxes don't need provisioning, you can generate a fresh pair per CI run with the run ID baked in — ci-{run_id}[email protected] and ci-{run_id}[email protected] — and never worry about state bleeding between runs or parallel jobs stepping on each other's mail. That also sidesteps one of the more annoying failure modes in flaky test suites: a leftover message from a previous run getting picked up by wait_for_mail and passing an assertion it shouldn't have.
If you're already testing password reset flows or magic link logins this way, email-change confirmation slots into the same harness — it just needs two addresses instead of one. And if your polling loop is tight enough to trip CyberTemp's rate limits during a big CI run, the backoff pattern in handling rate limits and retries applies here without changes.
Bottom line
If your test suite covers signup OTP and password reset but not email-change, you have a gap in exactly the flow that matters most for account security. The fix isn't a bigger framework — it's two disposable inboxes per test run instead of one, and an assertion that checks both.
If you're scripting this against CI, the paid tiers are where per-key request limits stop being the bottleneck on a suite that spins up a new inbox pair for every run. FREE covers the occasional manual check; ECO and CORE hold up under real CI volume; ELITE is for teams running this across many pipelines at once. Sign up if that's where you are.