Create virtual emails, read them via API
MAIL2REST is a REST API that lets you create unlimited virtual email addresses on your own private domain and read received emails as structured JSON — sender, subject, body, and attachments. Get notified instantly via webhooks or poll at your own pace. No SMTP server setup. 100% free, all features included.
How do I read emails via REST API?
Two API calls. No SMTP, no MX records, no mail server. Create a mailbox, read your emails as JSON.
Create a virtual mailbox
Send POST /api/virtualemails with an optional
custom address. Get back a unique email address ready to receive.
Read emails via REST
Call GET /api/emails/virtual/{id} to list all
received messages. Each email is returned as structured JSON:
from, subject, body,
and attachments[] as base64.
Optional: real-time webhooks
Want instant notifications? Set your endpoint URL via
POST /api/webhooks. Every incoming email triggers
a POST to your URL in under 200ms.
# 1. Create a virtual mailbox curl -X POST https://api.mail2rest.com/api/virtualemails \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"emailAddress": "test-inbox", "domainId": "..."}' # 2. Read received emails curl https://api.mail2rest.com/api/emails/virtual/a1b2c3d4 \ -H "Authorization: Bearer YOUR_API_KEY" # Response 200: { "data": [ { "id": "e5f6g7h8-...", "from": "alice@example.com", "subject": "Invoice #1042", "bodyText": "Please find attached...", "bodyHtml": "<p>Please find...</p>", "attachments": [ { "filename": "invoice.pdf" } ], "receivedAt": "2026-03-16T10:35:00Z" } ], "totalCount": 1 }
MAIL2REST vs Mailgun vs Mailtrap vs Mailinator
How MAIL2REST compares to other email API services for virtual mailbox creation and inbound email processing.
| Feature | MAIL2REST | Mailgun | Mailtrap | Mailinator |
|---|---|---|---|---|
| Virtual mailbox creation via API | ✓ Yes | ✗ No | ⚠ Limited | ✓ Yes |
| Read emails via REST API | ✓ JSON | ✗ No | ✓ Yes | ⚠ Limited |
| Real-time webhook delivery | ✓ <200ms | ✓ Yes | ✗ No | ✗ No |
| Private isolated inboxes | ✓ Yes | ✓ Yes | ✓ Yes | ✗ Shared |
| No SMTP required | ✓ Pure REST | ✗ SMTP setup | ✓ Yes | ✓ Yes |
| Private domains (BYO) | ✓ Yes | ✓ Yes | ✓ Yes | ⚠ Enterprise |
| Attachments as JSON | ✓ Yes | ⚠ Multipart | ✓ Yes | ✗ No |
| Production-grade SLA | ✓ 99.9% | ✓ 99.99% | ✓ 99.9% | ✗ No SLA |
| Completely free | ✓ Yes | ✗ Paid | ⚠ Limited | ✓ Yes |
What can you build with a virtual email API?
MAIL2REST is used by developers and teams to automate email workflows that would otherwise require maintaining an SMTP server.
Automated testing & CI/CD
Test signup verification, password reset, and transactional email flows end-to-end. Create a disposable mailbox per test run, trigger your app's email, assert on the received JSON payload, then delete. Works with GitHub Actions, GitLab CI, Azure DevOps, Jenkins.
Inbound email processing for SaaS
Receive customer emails programmatically — support tickets, form submissions, or inbound data. Parse sender, subject, body, and attachments as structured JSON via API or real-time webhooks. No mail server to maintain.
Disposable inboxes for QA & staging
Generate unlimited throwaway email addresses for QA environments. Each address is private, isolated, and auto-expires. No shared public inboxes, no leaked test data.
Custom domain email capture
Point your domain's MX records to MAIL2REST and capture every email sent to any address on your domain.
Process inbound email for your branded addresses (support@yourdomain.com, billing@yourdomain.com) via API.
How to receive emails in Python, Node.js, and cURL
MAIL2REST works with any language. Here are ready-to-use snippets.
# Python — read emails from a virtual mailbox import requests API = "https://mail2rest.com/api" HEADERS = {"Authorization": "Bearer YOUR_API_KEY"} # Create a virtual mailbox mailbox = requests.post(f"{API}/virtualemails", json={ "emailAddress": "test-inbox", "domainId": "your-domain-id", "expiresAt": "2026-04-01T00:00:00Z" }, headers=HEADERS).json() # Read received emails emails = requests.get( f"{API}/emails/virtual/{mailbox['id']}", headers=HEADERS ).json() for email in emails["data"]: print(f"From: {email['fromAddress']} — {email['subject']}")
// Node.js — read emails from a virtual mailbox const API = "https://mail2rest.com/api"; const headers = { "Authorization": "Bearer YOUR_API_KEY" }; // Create a virtual mailbox const mailbox = await fetch(`${API}/virtualemails`, { method: "POST", headers: { ...headers, "Content-Type": "application/json" }, body: JSON.stringify({ emailAddress: "test-inbox", domainId: "your-domain-id", expiresAt: "2026-04-01T00:00:00Z" }) }).then(r => r.json()); // Read received emails const emails = await fetch( `${API}/emails/virtual/${mailbox.id}`, { headers } ).then(r => r.json()); emails.data.forEach(e => console.log(`From: ${e.fromAddress} — ${e.subject}`));
Frequently asked questions about MAIL2REST
POST /api/virtualemails,
then retrieve received emails with GET /api/emails/virtual/{id}.
Each email is returned as structured JSON: from, to, subject, body
(text and HTML), and attachments encoded as base64. No SMTP server
or MX record configuration is required. You can also configure webhooks
to receive real-time notifications when new emails arrive.
inbox.yourcompany.com) and create virtual email
addresses on it. Setup requires a one-time MX record change pointing
to MAIL2REST servers — no SMTP configuration, no mail server
to maintain. All emails sent to any address on your domain are
automatically captured and available via the REST API. You can also
use the default mail2rest.com domain.
requests library: create a virtual mailbox with
POST /api/virtualemails, then poll received emails with
GET /api/emails/virtual/{id}. Every email is returned as
structured JSON — no email parsing library needed. For real-time
processing, configure a webhook to receive a POST request the instant an email arrives.
POST /api/virtualemails
before each test, (2) trigger your application's signup/verification email to that address,
(3) poll GET /api/emails/virtual/{id} or receive the webhook payload,
(4) extract the verification link from the email body, (5) complete the flow,
(6) delete the mailbox. This works in any CI/CD pipeline — GitHub Actions, GitLab CI,
Jenkins, Azure DevOps — with zero infrastructure to maintain.
Start reading emails via API in 5 minutes
Completely free. No credit card required. All features included.
Create your account →