
How to Test Digest and Batch Email Logic
Need a disposable inbox right now?
Spin up a temporary email address in seconds — no signup, no spam, no trace.
Digest emails are the hardest transactional email to test. A password reset fires once and you check one message. A daily or weekly digest has to aggregate events over a window, dedupe repeats, and decide when the batch is "done" — and none of that shows up until real time passes, unless you fake the clock and generate the traffic yourself.
This is a walkthrough for QA and backend engineers who need to verify digest and batching logic — activity summaries, weekly recap emails, "here's what you missed" notifications — without waiting real days for the job to run or burning a real inbox on every test pass.
Why digest emails break in ways single-send emails don't
A one-off transactional email has one failure mode: it either sends or it doesn't. A digest has several, and they're all invisible until the batch window closes:
Events that land right at the edge of the aggregation window get double-counted in the next digest, or dropped entirely.
Dedup logic that works for two events in the same request fails once events arrive from different queue workers seconds apart.
"Empty digest" suppression — not sending a summary when there's nothing to summarize — is often untested because most manual QA passes always have activity to report.
Batch jobs that re-run after a partial failure can re-send a digest with duplicate line items instead of resuming cleanly.
None of these show up in a single manual test. They only show up when you generate a realistic sequence of events against a real inbox and watch what actually lands.
Set up one inbox per test scenario
Don't reuse a single inbox across scenarios — mixed event streams make it hard to tell which digest run produced which email. Generate one disposable address per scenario, matching the case you're testing:
[email protected]
[email protected]
[email protected]
[email protected]
Point your test harness's user record at each address, then drive your application's normal event pipeline — comments, likes, price changes, whatever your digest actually summarizes — into each one under the specific timing pattern you're checking.
Poll instead of waiting on the real schedule
If your digest job runs on a cron schedule, don't wait for the schedule in CI. Trigger the job function directly with a manipulated "now," then poll the inbox for the result. A minimal Python harness:
import httpx, time
API_KEY = "tk_..."
HEADERS = {"X-API-Key": API_KEY}
BASE = "https://api.cybertemp.xyz"
def get_mail(email):
r = httpx.get(f"{BASE}/getMail", headers=HEADERS, params={"email": email})
r.raise_for_status()
return r.json()
def wait_for_digest(email, timeout=60, poll_every=3):
deadline = time.time() + timeout
while time.time() < deadline:
messages = get_mail(email)
if messages:
return messages[0]
time.sleep(poll_every)
return None
digest = wait_for_digest("[email protected]")
assert digest is not None, "digest job never fired"
assert "3 updates" in digest["subject"], digest["subject"]
GET /getMail?email=... also creates the inbox on first call, so there's no separate setup step — the first poll against a fresh address is the inbox creation. If you're testing OTP-style codes inside a digest confirmation step, the Go SDK's WaitForOTP helper does the polling and regex extraction in one call — that's a Pro-tier-and-up feature.
Test the empty-digest case on purpose
This is the scenario every team skips. Point an inbox at a user with zero qualifying events for the window, run the job, and assert that nothing arrives:
messages = get_mail("[email protected]")
assert messages == [], "digest sent for a user with no activity"
If your suppression logic is broken, this is the test that catches it — not a human squinting at a summary email trying to remember whether the "0 new comments" line is supposed to be there.
Check dedup by firing near-simultaneous events
Race conditions in dedup logic need events that arrive close together, not sequentially with a comfortable gap. Fire your test events with only tens of milliseconds between them, from separate concurrent requests if your event ingestion is queue-based, then check the resulting digest for duplicate line items:
Same event ID delivered twice — the digest should collapse it to one line.
Two different events referencing the same underlying object — the digest should show one merged entry, not two.
An event that arrives after the batch job has already started reading — it should land in the next digest, not get silently dropped.
Reading the resulting message body with GET /getMail lets you grep the returned HTML or text body for repeated identifiers and assert an exact count, which is far more reliable than a human scanning the email for duplicates.
Simulate retry-after-partial-failure
Digest jobs that batch-send to thousands of users usually checkpoint progress somewhere. Kill the job mid-run in a test environment, restart it, and confirm the affected inbox gets exactly one digest — not zero, not two:
run_digest_job(kill_after_n=50) # simulate crash partway through
run_digest_job() # resume / retry
messages = get_mail("[email protected]")
assert len(messages) == 1, f"expected 1 digest, got {len(messages)}"
This is the test most teams find out they needed only after a resumed job double-sent a week of activity to half their user base. Catching it against a disposable inbox in CI costs nothing; catching it in production costs a support queue.
Build a small library of edge-case addresses
Once you have a handful of scenario inboxes working, keep the naming pattern consistent and check it into your test fixtures — digest-<scenario>@cybertemp.xyz reads clearly in test output and in Slack when someone asks which case failed. Delete and recreate inboxes between full test suite runs with DELETE /inbox?email=... so old messages from a previous run don't leak into an assertion about the current one.
If you're just spot-checking a single digest by hand, open cybertemp.xyz, generate an inbox in the browser, and point your staging account's notification email at it — no login and no code required for a one-off look. For the full scenario suite described above, wired into CI with real assertions and run on every pull request, the paid tiers remove the per-key request ceiling that a free-tier key will hit once you're running dozens of scenario inboxes per build.