
How to Test Duplicate-Send Bugs With a Disposable Inbox
Need a disposable inbox right now?
Spin up a temporary email address in seconds — no signup, no spam, no trace.
A user complains they got the same "your order shipped" email three times. You check the send logs and see exactly one send event. The bug isn't in your logs — it's in the gap between "we called the email provider" and "the provider delivered exactly once," and most teams never test that gap until a customer finds it.
Why duplicate sends happen even when your code looks right
Most transactional email goes through at least one queue: a job fires, a worker picks it up, the worker calls the email provider. Queues default to at-least-once delivery, not exactly-once. If a worker crashes after sending but before acknowledging the job, the queue redelivers it, and the next worker sends the same email again. Add retry-with-backoff on a webhook that triggers the send, or a user double-clicking "resend confirmation," and you get the same failure from three different directions.
None of this shows up in a quick manual test. You click the button once, you get one email, you ship. The bug needs concurrency or a forced retry to surface, which is exactly what most pre-launch QA skips.
Your own inbox hides the problem
Testing in a real inbox makes this worse, not better. Gmail and Outlook both collapse near-identical messages into a thread, so two sends can look like one in the UI even when two separate messages landed. You also can't tell, just by reading the inbox, whether a duplicate arrived with the same Message-ID (a provider-level retry) or a new one (your application code actually called send twice) — and that distinction is exactly what tells you which layer to fix.
A disposable inbox fixes both problems. You get a flat list of raw messages with headers intact, and you throw the inbox away when the test run ends, so there's no thread history muddying the next test.
Give every test run its own inbox
Don't reuse one test address across runs — a leftover message from yesterday's test will throw off your count. Generate a fresh local part per run, tied to the scenario you're forcing:
[email protected]
[email protected]
[email protected]
Reading mail for an address that doesn't exist yet creates the inbox automatically, so there's no setup step before the test — you just read from the address you're about to use.
Script the forced duplicate, then poll and count
The test has three parts: trigger the send twice (or force the retry path your queue actually uses), wait for mail to land, and assert on the count and the headers — not just "an email arrived."
import httpx, timeAPI_KEY = "tk_..." HEADERS = {"X-API-Key": API_KEY} BASE = "https://api.cybertemp.xyz"
def get_mail(email): r = httpx.get(f"{BASE}/getMail", params={"email": email}, headers=HEADERS) r.raise_for_status() return r.json()
def wait_for_count(email, minimum, timeout=30, interval=2): deadline = time.time() + timeout while time.time() < deadline: mail = get_mail(email) if len(mail) >= minimum: return mail time.sleep(interval) return get_mail(email)
test_address = "[email protected]"
Trigger your send twice, or replay the webhook that fires it
trigger_order_shipped_email(test_address) trigger_order_shipped_email(test_address) # simulates a queue redelivery
mail = wait_for_count(test_address, minimum=1, timeout=20) message_ids = {m.get("messageId") for m in mail}
print(f"messages received: {len(mail)}") print(f"distinct Message-IDs: {len(message_ids)}")
If your idempotency guard is working, you should see exactly one message, with one Message-ID, no matter how many times you fire the trigger. If you see two messages with two different Message-IDs, the duplicate is coming from your application code calling send twice. If you see two messages sharing a Message-ID — rarer, but it happens with some provider retry behavior — the duplicate is at the transport layer, not yours to fix in application code.
What to actually assert, beyond "one email showed up"
A count of one isn't the whole test. Build the assertion around the specific failure mode you're forcing:
Idempotency key present and consistent. If your job payload carries an idempotency key, the second send attempt with the same key should be a no-op at the provider or queue level, not just suppressed after the fact.
Content matches on legitimate resends. A password-reset "resend" button should produce a new, valid-but-different link each time — if your test sees byte-identical content across two intentional resends, the old link probably never expired.
Timing gaps match your backoff config. Pull the received timestamps from the two messages and confirm the gap matches your retry schedule — a near-zero gap usually means two independent triggers, not one retry.
Count stays at one under real concurrency. Fire the trigger from two threads at once instead of sequentially. Sequential double-calls catch missing idempotency keys; concurrent calls catch race conditions a sequential test can't reach.
Where the bug usually turns out to live
After running this pattern across a few different stacks, the root cause tends to land in one of four places: a queue consumer that acknowledges the job after sending instead of before, a missing unique constraint on the "has this event already been processed" table, a webhook handler that doesn't check the event ID against anything it's already seen, or a frontend retry that fires a second request before the first one's response comes back. None of these are visible from a single manual click-through — they all need the forced-duplicate pattern above to surface. If the scenario involves a webhook replaying under load rather than a user double-click, pair this test with a look at how your API scripts handle rate limits and retries — the same backoff logic that protects you from a 429 is often the same code path that's firing your duplicate send.
This fits the same pattern as wiring up signup-flow tests or OTP test automation — one disposable inbox per test run, poll until the mail you expect (or don't expect) shows up, assert on the real content instead of a log line that says "sent successfully."
If you're scripting against signups, retries, and webhook replays as part of a CI suite, the paid tiers are where per-key request limits stop being the bottleneck for running dozens of these scenarios in parallel. Sign up if that's your pipeline.