How to receive incoming email by webhook
Polling an inbox every two seconds works, but a webhook is faster and quieter: QuickInbox calls your URL the moment an email lands.
Set the webhook
Webhooks are set per namespace, from your workspace or with the API:
curl -X PATCH "https://business.quickinbox.net/api/business/namespaces/1/webhook" \
-H "X-API-Key: $QI_KEY" -H "content-type: application/json" \
-d '{"webhookUrl": "https://ci.example.com/hooks/mail"}'Webhooks are included on every plan, including Free. Check the exact request body in the API docs.
The payload
{
"event": "mail.received",
"namespace": "acme7x",
"message": {
"id": "b2c3d4e5-...",
"to": "acme7x.signup-test",
"from": "sender@example.com",
"subject": "Confirm your signup",
"text": "...",
"html": "...",
"spam": { "score": 100, "spf": "pass", "dkim": "pass", "dmarc": "pass" },
"receivedAt": 1893455460
}
}The to field is namespace.tag, without the domain, so you can match it to the tag your test used.
A small receiver (Node)
import http from 'node:http';
const waiting = new Map(); // tag -> resolve function
export function waitForWebhookEmail(tag, timeoutMs = 60_000) {
return new Promise((resolve, reject) => {
waiting.set(tag, resolve);
setTimeout(() => reject(new Error(`No webhook for ${tag}`)), timeoutMs);
});
}
http.createServer((req, res) => {
let body = '';
req.on('data', (c) => (body += c));
req.on('end', () => {
const { message } = JSON.parse(body);
const tag = message.to.split('.').slice(1).join('.');
waiting.get(tag)?.(message);
res.end('ok');
});
}).listen(8787);Keep a fallback
Failed webhook deliveries aren't retried. If the guarantee matters, poll GET /api/business/mail after a timeout, or use the live stream endpoint GET /api/business/mail/stream. Treat the webhook as the fast path and the API as the safety net.
Testing locally?
Your laptop isn't reachable from the internet. Use a tunnel tool, or simply poll the API locally and use the webhook in CI.
Related guides
- Email testing tools compared: QuickInbox, Mailtrap, Mailosaur, Mailinator, MailSlurp, testmail
- How to test email verification in Selenium with Python
- Email testing in Jest and Node.js
- Email testing in Python with pytest
- Email testing API overview
Get private inboxes: the QuickInbox Business API has a free plan with 5,000 emails a month, and paid plans from $9. Create a free account or read the API docs.