REST API · Private domains · No SMTP

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.

<200ms
Webhook delivery
Unlimited mailboxes
99.9%
Uptime SLA
BYO
Private domains

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.

1

Create a virtual mailbox

Send POST /api/virtualemails with an optional custom address. Get back a unique email address ready to receive.

2

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.

3

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.

read-emails.sh
# 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.

CI

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.

SaaS

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.

QA

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.

BYO

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.

receive-email.py
# 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']}")
receive-email.js
// 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

Create a virtual mailbox with 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.
Mailinator provides shared, public inboxes primarily for manual testing. MAIL2REST provides private, isolated virtual mailboxes on your own domain with API key authentication, REST inbox access, optional webhook delivery, and a 99.9% uptime SLA. MAIL2REST is built for production use — automated testing pipelines, SaaS email workflows, and programmatic email processing — not just manual inbox checks.
Yes. MAIL2REST is commonly used for end-to-end testing of email flows: signup verification, password reset, transactional email validation. The typical pattern: create a mailbox before each test run, trigger your application's email, receive and assert on the webhook payload, then delete the mailbox. Works with any CI/CD pipeline — GitHub Actions, GitLab CI, Azure DevOps, Jenkins.
No. MAIL2REST is entirely REST-based. You create mailboxes, retrieve emails, configure webhooks, and manage everything through standard HTTP endpoints with JSON payloads. No SMTP server, no MX records (on the default domain), no port 25 configuration. For custom domains, a one-time MX record change is required.
MAIL2REST is completely free. Every account gets full access to all features: mailboxes, webhooks, custom domains, and the full REST API. No credit card required, no paid plans, no hidden costs.
Yes. You can bring your own domain (e.g. 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.
Any language that can make HTTP requests. MAIL2REST is a standard REST API with JSON payloads. Webhook payloads are standard JSON POST requests, compatible with any web framework — Node.js, Python, C#/.NET, PHP, Go, Ruby, Java, and more.
With MAIL2REST, you don't need to configure IMAP, POP3, or an SMTP server. Use the 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.
MAIL2REST is a strong Mailinator alternative for automated testing. Key differences: MAIL2REST inboxes are private and isolated (not shared/public), emails are accessible via authenticated REST API (not a web UI), real-time webhooks are available for instant processing, and you can use your own custom domain. It's completely free with no feature restrictions.
The pattern: (1) create a disposable mailbox via 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 →