API Endpoints
Basic Operations
GET List Messages GET Get Message Metadata GET Get HTML Content GET Get Plain Text GET Get Message Source GET Download as EMLREST API
Complete API reference for MailCatcher NG. All endpoints are local only and require no authentication.
Basic Operations
/messages Returns JSON array of all messages with basic metadata.
curl http://127.0.0.1:1080/messages Response
[
{
"id": 1,
"from": ["sender@example.com"],
"to": ["recipient@example.com"],
"subject": "Test Email",
"created_at": "2024-01-10T10:30:00Z"
}
] /messages/:id.json Returns detailed metadata for a specific message including headers, sender, recipients, and body info.
curl http://127.0.0.1:1080/messages/1.json /messages/:id.html Returns the HTML version of the message rendered in the browser.
curl http://127.0.0.1:1080/messages/1.html /messages/:id.plain Returns the plain text version of the message.
curl http://127.0.0.1:1080/messages/1.plain /messages/:id.source Returns the complete raw email source in MIME format.
curl http://127.0.0.1:1080/messages/1.source /messages/:id.eml Downloads the message as an EML file (RFC 822), suitable for importing into email clients.
curl -O http://127.0.0.1:1080/messages/1.eml Advanced Operations
/messages/:id/transcript.json Returns the SMTP transcript including all commands, responses, and TLS details for debugging connection issues.
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
/messages/:id.transcript Returns SMTP transcript rendered as an HTML page for viewing in a browser.
curl http://127.0.0.1:1080/messages/1.transcript /messages/:id/parts/:cid Downloads a specific message part or attachment by its Content-ID.
# 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 /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)
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" /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
# 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" /messages/:id/links.json Returns all links found in the message with metadata about their purpose (verification, unsubscribe, etc).
curl http://127.0.0.1:1080/messages/1/links.json /messages/:id/parsed.json Returns comprehensive structured data parsed from the message including verification URLs, OTP codes, reset tokens, and all links.
curl http://127.0.0.1:1080/messages/1/parsed.json /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)
curl http://127.0.0.1:1080/messages/1/accessibility.json Management
/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.
# 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 /messages/:id Deletes a specific message from storage.
curl -X DELETE http://127.0.0.1:1080/messages/1 /messages Clears all stored messages.
curl -X DELETE http://127.0.0.1:1080/messages System
/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
curl http://127.0.0.1:1080/server-info /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
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);
}
}; / Terminates the MailCatcher server instance.
⚠️ Warning: This will shut down the server. Use the --no-quit flag to disable this endpoint.
curl -X DELETE http://127.0.0.1:1080/