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 Referral Emails Without Spamming Real Friends

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

Referral and invite-a-friend features are hard to test honestly. The flow only exists because two different inboxes are involved — the sender who clicks "invite a friend" and the friend who receives the email with the referral link — and most teams end up testing it with two of their own personal addresses, or worse, asking a coworker to keep clicking a link they've already clicked ten times this sprint. That gets you a pass on the happy path and nothing on the parts that actually break in production.

Why referral testing burns real inboxes

A referral system has more moving parts than a plain signup email: a unique code or token per invite, a campaign or attribution parameter, a reward that triggers on the friend's signup (not the invite), and usually a dedupe check so the same friend can't be invited five times for five rewards. None of that shows up if your test plan is "send myself an invite and see if it arrives." You need a fresh, disposable "friend" for every test run, and you need to actually read what got sent, not just confirm an email fired.

Using real coworker inboxes doesn't scale past a handful of manual checks, and it pollutes the data you're trying to protect in the first place — now there's a fake referral relationship between two employees sitting in your production database. A throwaway address avoids both problems: it's disposable, and nobody has to remember to delete the resulting test account later.

Give every test run its own "referred friend" address

The pattern is the same one that works for any burner-per-context testing: generate one address per invite, name it so you can tell at a glance what it's for, and never reuse it across runs. Something like [email protected] or [email protected] works — the local part just needs to be unique and readable in a log line six months from now.

CyberTemp doesn't require a setup call to start using an address like that. Reading mail for it is also how the inbox gets created — there's no separate step to provision it first.

curl "https://api.cybertemp.xyz/[email protected]" \
  -H "X-API-Key: tk_..."

The first call against a new address returns an empty array. That's expected — it means the inbox now exists and is ready to receive the invite your test is about to trigger.

Pull the invite and check what actually shipped

Once your test triggers the "invite a friend" action, poll the same endpoint until the message shows up, then actually parse it instead of eyeballing the inbox. A short Python script covers this without needing a published SDK:

import httpx, re, time

API_KEY = "tk_..." HEADERS = {"X-API-Key": API_KEY} BASE = "https://api.cybertemp.xyz" FRIEND_ADDR = "[email protected]"

def wait_for_invite(timeout=60, interval=3): deadline = time.time() + timeout while time.time() < deadline: r = httpx.get(f"{BASE}/getMail", params={"email": FRIEND_ADDR}, headers=HEADERS) r.raise_for_status() messages = r.json() if messages: return messages[0] time.sleep(interval) raise TimeoutError("referral invite never arrived")

msg = wait_for_invite() link_match = re.search(r'href="([^"]+ref=[^"]+)"', msg.get("html", msg.get("body", ""))) assert link_match, "no referral link with a ref param found in the invite email"

referral_link = link_match.group(1) print("referral link:", referral_link)

That's the whole check, but it's checking something a "did an email send" assertion never catches: is there actually a referral parameter on the link, and does it point at the right campaign or sender ID? A referral email that sends but drops the tracking parameter looks identical to a working one until someone notices attribution numbers don't add up weeks later.

The edge cases that referral bugs hide in

Once the happy path is covered, the interesting bugs live in a short list of specific states worth testing on purpose:

  • Inviting the same friend address twice — does the system silently resend, refuse, or (worst case) issue a second reward?

  • The friend signing up through the link but never completing onboarding — does the reward fire on click or on a completed account, and does your test actually distinguish the two?

  • An expired or already-claimed referral code — the email should still describe what happened instead of linking to a dead page.

  • A sender inviting an address that's already an existing user — this is the case most referral systems get wrong first, because it's the one nobody thinks to write a fixture for.

Each of those needs its own disposable friend address so the runs don't collide. Naming them by scenario instead of by number — [email protected], [email protected] — makes the test suite readable a year later, which matters more than it sounds once three people are maintaining it.

Wire it into CI once the manual pass is clean

The same polling function works unattended once you trust it. Drop the friend-address generation into your test setup — a UUID or run ID appended to a fixed prefix keeps every CI run isolated from the last one — and tear the inbox down afterward with DELETE /inbox?email=... so you're not accumulating throwaway inboxes against your plan's limit run after run.

Nothing about the pattern above needs more than the raw API and a request library, and it runs the same way on a laptop as it does in a pipeline. If the suite grows into something that's checking dozens of referral scenarios a night, the Go and Rust SDKs add WaitForMessage and WaitForOTP helpers that replace the manual polling loop — those ship on CORE and ELITE, where an unattended pipeline is expected to be running against the API in the first place.

Bottom line

Referral emails break in ways that "an email arrived" never catches — missing tracking parameters, rewards firing on the wrong event, duplicate invites that should have been blocked. A disposable inbox per test run turns those into things you can assert on directly instead of things a support ticket surfaces three weeks after launch. It's the same pattern already covered for testing transactional emails generally and for OTP test automation — applied to the one email flow that involves two separate inboxes instead of one.

If you're scripting against signups and invite flows as part of a real test suite, the paid tiers are where per-key request limits stop being the thing you're working around, and where the SDK helpers above start paying for themselves. Check the pricing page if that's the stage you're at.

Share
    How to Test Referral Emails Without Spamming Real Friends | CyberTemp Blog