REST API · JSON · CORS Enabled

API Reference

Integrate TMail's disposable email service into your application. All endpoints return JSON and support CORS.

Base URL: https://yourdomain.com
GET /api/domains.php List active domains

Returns all active email domains available for generating addresses.

{"success": true, "domains": ["mail.yoursite.com", "inbox.yoursite.com"]}
GET /api/generate.php Generate random email

Generates a random temporary email address from available domains.

{"success": true, "email": "x7k2mq9w@mail.yoursite.com", "username": "x7k2mq9w", "domain": "mail.yoursite.com"}
GET /api/messages.php?email={email} Get inbox

Returns all messages for the specified email (last 50, newest first).

{"success": true, "count": 1, "messages": [{"id": "uuid", "sender": "noreply@x.com", "subject": "Your code is 123456", "size": 1024, "created_at": "2024-01-15T10:30:00.000Z"}]}
GET /api/messages.php?id={id}&email={email} Get full message

Returns the full content including HTML and text body.

{"success": true, "message": {"id": "uuid", "recipient": "x@mail.site.com", "sender": "no-reply@example.com", "subject": "Verify", "body_html": "<html>...</html>", "body_text": "Your code is 123456", "created_at": "..."}}
DELETE /api/messages.php?id={id}&email={email} Delete message

Deletes a specific message. Requires matching email for security.

{"success": true, "message": "Deleted"}
GET /api/stats.php Public stats
{"success": true, "stats": {"active_domains": 2, "total_messages": 15420, "messages_today": 287}}

💻 Code Examples

const BASE = 'https://yourdomain.com'; // Generate temporary email const gen = await fetch(`${BASE}/api/generate.php`).then(r => r.json()); console.log('Email:', gen.email); // Check inbox every 3 seconds setInterval(async () => { const inbox = await fetch(`${BASE}/api/messages.php?email=${encodeURIComponent(gen.email)}`).then(r => r.json()); for (const msg of inbox.messages) { console.log(`From: ${msg.sender} | Subject: ${msg.subject}`); // Get full message const full = await fetch(`${BASE}/api/messages.php?id=${msg.id}&email=${encodeURIComponent(gen.email)}`).then(r => r.json()); console.log('Body:', full.message.body_text); } }, 3000);

⚡ Rate Limits

EndpointLimitWindow
/api/*60 requests60 seconds / IP
/api/admin/login.php5 attempts15 minutes / IP