Skip to content

Signing up for Discord? Some of our domains are accepted there. See which ones on the Domains page.

CyberTemp
All posts

How to Test CC and BCC Leaks Before You Ship

CyberTemp6 min read

Need a disposable inbox right now?

Spin up a temporary email address in seconds — no signup, no spam, no trace.

Get a free inbox

A team-invite email that CCs every existing member instead of BCCing them hands a full roster of coworker addresses to whoever gets invited next. A "your document was shared" notification that lists every other viewer in the To field does the same thing. These bugs render perfectly, pass a visual review, and never show up until a user notices a stranger's email sitting in their inbox header — usually in a support ticket, not a test run.

Why CC/BCC bugs survive code review

Recipient-list bugs are invisible from the sending side. The developer who wrote the notification sees one call to their email provider with a list of addresses attached, and that call either succeeds or fails — it doesn't tell you whether those addresses landed in To, Cc, or Bcc. The only place the distinction is visible is inside the message headers that each recipient actually receives, and almost nobody inspects those in a test suite.

It's also a bug that survives refactors unusually well. A template rename, a provider migration, or a switch from one notification library to another can flip a `bcc` field to a `cc` field in a config object without touching any logic a reviewer would flag. The send still works. The test still passes, if the test only checks that mail arrived.

Where this actually shows up

A short list of the real patterns worth testing for, not a generic "check your emails" reminder:

  • Team-invite emails that list existing members as CC so the new invitee sees the whole roster's addresses on arrival.

  • Shared-document or shared-calendar notifications that expose every other collaborator's address in the visible header instead of hiding them.

  • A "we fixed it" patch that moves addresses from Bcc to Cc because a provider's SDK renamed the field and the migration script didn't catch every call site.

  • Group notification digests where a dedup step merges recipient lists incorrectly, so one recipient's personal unsubscribe token or account ID ends up visible to another.

Each of these ships clean. The rendered email looks identical whether the other addresses are hidden or exposed — the only way to catch it is to look at what each separate recipient actually received.

Testing it with disposable inboxes standing in for a team

The test that actually catches this needs more than one mailbox, because the bug is about what one recipient can see about another. Generate a handful of disposable addresses to stand in for a fake team, trigger the real notification path against all of them, then pull each inbox back separately and check what each one was allowed to see.

GET /getMail creates the inbox on first read, so there's no setup call before the test — just pick unique local parts per run and poll each one after triggering the send.

import httpx
import time

API_KEY = "tk_..." HEADERS = {"X-API-Key": API_KEY} BASE = "https://api.cybertemp.xyz"

team = [ "[email protected]", "[email protected]", "[email protected]", ]

def invite_new_member(existing_addresses, new_address): # call your own staging API here to trigger the real invite email ...

def wait_for_message(email, timeout=30, interval=2): deadline = time.time() + timeout while time.time() < deadline: resp = httpx.get(f"{BASE}/getMail", params={"email": email}, headers=HEADERS) resp.raise_for_status() messages = resp.json() if messages: return messages[0] time.sleep(interval) raise TimeoutError(f"no message arrived for {email}")

invite_new_member(team[:2], team[2]) received = wait_for_message(team[2]) print(received)

Print the raw message before writing a single assertion. Some pipelines expose headers as a separate field on the message object, others only hand back a rendered body with the header block folded into the text. Assert against whatever shape you actually get back, not a schema you're assuming — a check written against the wrong field passes for the wrong reason and tells you nothing the next time the bug actually happens.

What to actually assert

"The invite arrived" only proves the send pipeline works. The leak check needs three separate assertions:

  • The new recipient's copy of the message does not contain any of the other team members' addresses anywhere in the visible header or body — not just the To field, since some templates helpfully print "shared with: alice@, bob@" in the message text itself.

  • Every existing member's copy, if your flow also notifies them, doesn't expose the new member's address to people who shouldn't have it yet depending on your product's invite-visibility rules.

  • The behavior holds across every notification type that fans out to a group — invite emails, shared-resource notifications, digest emails — not just the one template someone remembered to check after the last incident.

A visual review of the rendered email will never catch this, because the email looks completely normal to the person reading it. The bug only exists in what a different recipient's copy contains, which means the test has to compare across inboxes, not just inspect one.

Wiring it into CI without the inboxes colliding

Give every CI run its own set of team addresses — a run ID or short random suffix appended to each local part — so parallel test jobs and retries never read each other's mail. There's no inbox to tear down afterward; unused addresses age out on their own; see how to manage temp mail inboxes before you hit a limit if a run creates enough of them that housekeeping starts to matter.

Treat a leak as a hard failure, not a logged warning. This is the kind of bug that's embarrassing in exactly the way a silent warning guarantees it reaches production: nobody reads warnings until a user reports a stranger's email address showing up where it shouldn't.

Who should add this check

If your product never sends an email to more than one person at a time, this doesn't apply to you. The moment a feature fans a single event out to a group — invites, shared access, digests, team notifications — a recipient-list test belongs in the same suite as your Reply-To header checks, because both are bugs that are invisible from a single rendered copy and only show up by inspecting what actually arrived. The broader pattern of pulling real messages back through an API instead of trusting the template is covered in testing transactional emails without a real inbox.


If you're wiring this into a real CI pipeline across every group-notification template, the paid tiers are where the API stops being the bottleneck — CORE is the point where per-key limits stop capping how many fake team members you can spin up per run. Sign up if that's the pipeline you're building.

Share
    How to Test CC and BCC Leaks Before You Ship | CyberTemp Blog