REST API

Complete API reference for MailCatcher NG. All endpoints are local only and require no authentication.

GET Retrieve data
POST Create/Execute
DELETE Remove data
View Code Examples

Basic Operations

GET /messages

Returns JSON array of all messages with basic metadata.

Request
curl http://127.0.0.1:1080/messages

Response

json
[
  {
    "id": 1,
    "from": ["sender@example.com"],
    "to": ["recipient@example.com"],
    "subject": "Test Email",
    "created_at": "2024-01-10T10:30:00Z"
  }
]
GET /messages/:id.json

Returns detailed metadata for a specific message including headers, sender, recipients, and body info.

bash
curl http://127.0.0.1:1080/messages/1.json
GET /messages/:id.html

Returns the HTML version of the message rendered in the browser.

bash
curl http://127.0.0.1:1080/messages/1.html
GET /messages/:id.plain

Returns the plain text version of the message.

bash
curl http://127.0.0.1:1080/messages/1.plain
GET /messages/:id.source

Returns the complete raw email source in MIME format.

bash
curl http://127.0.0.1:1080/messages/1.source
GET /messages/:id.eml

Downloads the message as an EML file (RFC 822), suitable for importing into email clients.

bash
curl -O http://127.0.0.1:1080/messages/1.eml

Advanced Operations

GET /messages/:id/transcript.json

Returns the SMTP transcript including all commands, responses, and TLS details for debugging connection issues.

Request
curl http://127.0.0.1:1080/messages/1/transcript.json

Includes

  • • Session ID and client/server connection details
  • • TLS protocol version and cipher suite
  • • Complete SMTP command/response transcript
  • • Connection timing information
GET /messages/:id.transcript

Returns SMTP transcript rendered as an HTML page for viewing in a browser.

bash
curl http://127.0.0.1:1080/messages/1.transcript
GET /messages/:id/parts/:cid

Downloads a specific message part or attachment by its Content-ID.

bash
# First, get the message metadata to find attachment CIDs
curl http://127.0.0.1:1080/messages/1.json | jq '.parts'

# Then download the attachment
curl -O http://127.0.0.1:1080/messages/1/parts/image-001
GET /messages/search

Search messages across subject, sender, recipient, and body content with optional filtering.

Query Parameters

q - Search query (required)

has_attachments - Filter by attachments (true/false)

from - Start date (ISO 8601)

to - End date (ISO 8601)

bash
curl "http://127.0.0.1:1080/messages/search?q=verification&has_attachments=false"

curl "http://127.0.0.1:1080/messages/search?q=noreply@example.com&from=2024-01-01&to=2024-01-31"
GET /messages/:id/extract

Extracts verification tokens, magic links, OTP codes, or reset tokens from message content.

Query Parameters

type - Type to extract: token, link, or otp

bash
# Extract OTP code
curl "http://127.0.0.1:1080/messages/1/extract?type=otp"

# Extract magic link
curl "http://127.0.0.1:1080/messages/1/extract?type=link"

# Extract reset token
curl "http://127.0.0.1:1080/messages/1/extract?type=token"
GET /messages/:id/parsed.json

Returns comprehensive structured data parsed from the message including verification URLs, OTP codes, reset tokens, and all links.

bash
curl http://127.0.0.1:1080/messages/1/parsed.json
GET /messages/:id/accessibility.json

Analyzes HTML email for accessibility issues and returns a score (0-100) with recommendations.

Score Breakdown

  • images_with_alt - Percentage of images with alt text
  • semantic_html - Use of semantic HTML tags
  • score - Overall accessibility score (0-100)
bash
curl http://127.0.0.1:1080/messages/1/accessibility.json

Management

POST /messages/:id/forward

Forwards the caught email to its original recipient(s) using a configured SMTP server. Useful for final validation after testing.

Note: Requires MailCatcher to be started with SMTP forwarding configuration.

bash
# Start MailCatcher with forwarding enabled
mailcatcher \
  --forward-smtp-host smtp.example.com \
  --forward-smtp-port 587 \
  --forward-smtp-user your-username@example.com \
  --forward-smtp-password your-password

# Then forward a message
curl -X POST http://127.0.0.1:1080/messages/1/forward
DELETE /messages/:id

Deletes a specific message from storage.

bash
curl -X DELETE http://127.0.0.1:1080/messages/1
DELETE /messages

Clears all stored messages.

bash
curl -X DELETE http://127.0.0.1:1080/messages

System

GET /server-info

Returns server configuration and status information.

Response Includes

  • • MailCatcher version
  • • HTTP and SMTP server ports
  • • Hostname and IP addresses
  • • Connection counts and statistics
bash
curl http://127.0.0.1:1080/server-info
GET /messages (WebSocket)

Upgrades the HTTP connection to WebSocket for receiving real-time notifications about new messages, deletions, and clears.

Message Types

  • add - New message arrived
  • remove - Message was deleted
  • clear - All messages cleared
javascript
const ws = new WebSocket('ws://127.0.0.1:1080/messages');

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);

  if (data.type === 'add') {
    console.log('New message:', data.message);
  } else if (data.type === 'remove') {
    console.log('Message deleted:', data.id);
  }
};
DELETE /

Terminates the MailCatcher server instance.

⚠️ Warning: This will shut down the server. Use the --no-quit flag to disable this endpoint.

bash
curl -X DELETE http://127.0.0.1:1080/