Automate Signup & OTP Tests With the Free EduMails REST API
Eliminate flaky shared QA mailboxes. Provision a fresh temporary inbox per test run, lock it with a password, and poll verification codes in Playwright or Python.
Using EduMails’ free JSON REST API at https://api.edu-mails.com/api, each CI job can call POST /emails/generate for a fresh isolated address, lock it via PUT /emails/{uuid}/password, and poll GET /emails/{uuid} until the verification code arrives—zero API keys required.
Why shared QA mailboxes break CI pipelines
When parallel Playwright or Pytest jobs reuse a single static Gmail test mailbox, tests collide on stale OTP codes, hit IMAP rate limits, and leak OAuth credentials into CI secrets. Provisioning a dedicated disposable inbox per test run keeps every signup, password-reset, and magic-link test completely deterministic.
The 4-step EduMails REST API workflow
| Step | Endpoint | Purpose |
|---|---|---|
| 1. List domains | GET /api/domains?tld=.edu.pl | Check active public domains (supports optional tld filter) |
| 2. Create inbox | POST /api/emails/generate | Generate a fresh random or custom address and receive its uuid |
| 3. Lock inbox | PUT /api/emails/{uuid}/password | Optional: protect the test inbox before triggering outbound mail |
| 4. Poll messages | GET /api/emails/{uuid} | Fetch arriving emails (pass X-Inbox-Password if locked) |
Playwright (Node.js) signup & OTP test helper
const API = 'https://api.edu-mails.com/api';
export async function createLockedTestInbox(password) {
const res = await fetch(`${API}/emails/generate`, {
method: 'POST',
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'random', tld: '.edu.pl' }),
});
const { data } = await res.json();
const { uuid, address } = data.email;
await fetch(`${API}/emails/${uuid}/password`, {
method: 'PUT',
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
body: JSON.stringify({ password }),
});
return { uuid, address, password };
}
export async function waitForOtp({ uuid, password }, timeoutMs = 45000) {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
const res = await fetch(`${API}/emails/${uuid}`, {
headers: { 'Accept': 'application/json', 'X-Inbox-Password': password },
});
const { data } = await res.json();
const latest = (data?.messages || [])[0];
if (latest) {
const text = `${latest.subject || ''} ${latest.body || ''}`.replace(/<[^>]+>/g, ' ');
const match = text.match(/\b(\d{6})\b/);
if (match) return { code: match[1], message: latest };
}
await new Promise((r) => setTimeout(r, 4000));
}
throw new Error('Timed out waiting for OTP email');
}
Python (requests) polling snippet
import re, time, requests
API = "https://api.edu-mails.com/api"
headers = {"Accept": "application/json", "Content-Type": "application/json"}
inbox = requests.post(f"{API}/emails/generate", json={"action": "random"}, headers=headers, timeout=15).json()["data"]["email"]
uuid, address = inbox["uuid"], inbox["address"]
print("Testing signup with:", address)
# Trigger your app's signup email here, then poll every 5s
for _ in range(10):
msgs = requests.get(f"{API}/emails/{uuid}", headers={"Accept": "application/json"}, timeout=15).json()["data"]["messages"]
if msgs:
body = re.sub(r"<[^>]+>", " ", msgs[0].get("body", ""))
m = re.search(r"\b(\d{6})\b", body)
if m:
print("Extracted OTP:", m.group(1))
break
time.sleep(5)
Polite polling & security tips for CI
- Poll at a 4–6 second interval with an upper timeout (45–60s) instead of tight loops.
- Always keep
X-Inbox-Passwordvalues masked in GitHub Actions or GitLab CI logs. - Only test applications and staging domains you own or are explicitly authorized to test.
Frequently asked questions
Do I need an API key to call https://api.edu-mails.com/api?
No. The public endpoints listed on /api.html work without registration or an API key.
How often should my Playwright or Python test poll GET /emails/{uuid}?
Poll every 4 to 6 seconds for up to 45–60 seconds. Tight sub-second loops waste bandwidth and may trigger rate limiting.
Can I test HTML email layout as well as 6-digit OTPs?
Yes. Each message object returned by GET /emails/{uuid} includes the subject, sender, timestamps, and HTML/text body so you can assert links and templates.
Need a free receive-only inbox now?
Generate a temporary .edu.pl or .org address on EduMails in one click, lock it with an optional password, or automate tests with our free public REST API.