Overview
IQMailPilot captures email sent to addresses on your server domain. Your product sends that mail over SMTP. Your tests (or any HTTP client) then read it through the REST API using an API key.
- Create an email server in the dashboard and note its SMTP settings and domain.
- Configure your application mailer with those SMTP settings.
- Create an API key if your tests need to wait for or inspect messages.
- From the test suite, authenticate with the API key and call the messages API.
Sending mail does not require an API key. An API key is required only when you call the HTTP API.
Required credentials
Use only the variables that match what you are integrating. Do not treat the full set as mandatory for every consumer.
Application mailer (SMTP)
Required when your application delivers mail into IQMailPilot:
| Variable | Required | Source |
|---|---|---|
SMTP_HOST | Yes | Server page → Connect via SMTP |
SMTP_PORT | Yes | Server page → Connect via SMTP |
SMTP_USER | Yes | Server page → Connect via SMTP |
SMTP_PASS | Yes | Generate password on the server page |
Recipient address | Yes | Any local-part on the server domain suffix shown in the dashboard |
The recipient is application data, not an IQMailPilot secret. You may build it at runtime (recommended for parallel tests) or store a fixed address in configuration.
Test suite or automation (API)
Required when code must list, wait for, search, or delete messages over HTTP:
| Variable | Required | Source |
|---|---|---|
MAILPILOT_API_KEY | Yes | Dashboard → API keys (shown once at creation) |
MAILPILOT_SERVER_ID | Yes | Server page → Server ID (UUID). Not the short server key. |
MAILPILOT_API_URL | Yes* | API origin without a path. Current deployment default: https://api.iqmailpilot.com |
*If omitted in the TypeScript SDK, the client defaults to http://localhost:3001. Production and remote environments must set the correct origin explicitly.
What each credential is for
| Credential | Role | Bound to |
|---|---|---|
| SMTP username / password | Authenticate SMTP submission into a server | One email server |
| API key | Authenticate REST / SDK access | One workspace (with optional scopes) |
Create a server
- Sign in and open Dashboard → Servers.
- Select New server, enter a name, and create the server.
- Open the server. Record:
- Server ID — UUID used by the API (
MAILPILOT_SERVER_ID). - Server key and domain suffix — used to form recipient addresses (
local-part@<domain-suffix>). - Connect via SMTP — host, port, username, and a generated password.
- Server ID — UUID used by the API (
Every address on the server domain is accepted. You do not need to register recipients before sending.
Configure your application (SMTP)
Point your existing mail transport at the SMTP values from the server page. No API key is involved in this step.
SMTP_HOST=<host from Connect via SMTP>
SMTP_PORT=<port from Connect via SMTP>
SMTP_USER=<username from Connect via SMTP>
SMTP_PASS=<password generated on the server page>When the application sends mail, set the recipient to an address on that server's domain suffix. For automated tests, use a unique local-part per run so parallel jobs do not share the same inbox address.
<unique-local-part>@<domain-suffix-from-server-page>After sending, confirm delivery in Dashboard → Servers by opening the server and inspecting the message list. SMTP-only integrations can stop here.
Create an API key
- Open Dashboard → API keys.
- Select New key. Provide a name that identifies the consumer (for example the CI job or service that will use it).
- Assign permissions. For suites that only wait for and read messages, enable
servers:readandmessages:read. Enable write scopes only when the consumer must purge inboxes, delete messages, or manage servers. - Create the key and copy the secret immediately. IQMailPilot stores a hash only; the full value cannot be retrieved later.
- Store the secret in your secret manager or CI variables. Do not commit it to source control.
Key prefixes indicate environment: mp_test_ outside production, mp_live_ in production.
Configure your test suite (API)
Set the following for any process that calls the IQMailPilot HTTP API:
MAILPILOT_API_URL=https://api.iqmailpilot.com
MAILPILOT_API_KEY=<secret from Dashboard → API keys>
MAILPILOT_SERVER_ID=<Server ID UUID from the server page>The test must also know the recipient address used when the application sent the message. Pass that value to wait / waitFor as sentTo.
Authentication
Include the API key on every request using one of the following headers:
Authorization: Bearer <MAILPILOT_API_KEY>
X-Api-Key: <MAILPILOT_API_KEY>- REST base path:
https://api.iqmailpilot.com/api/v1 - The key is bound to a workspace.
X-Workspace-Idis optional; if sent, it must match the key's workspace. - Creating, listing, and revoking API keys requires a signed-in dashboard session. Those management routes do not accept an API key.
Wait for a message
Prefer the long-poll wait endpoint over fixed sleeps. It returns when a matching message exists, or fails when the timeout elapses.
TypeScript SDK
pnpm add @mailpilot/sdkimport { MailpilotClient } from '@mailpilot/sdk';
const client = new MailpilotClient({
apiKey: process.env.MAILPILOT_API_KEY!,
baseUrl: process.env.MAILPILOT_API_URL!,
});
const serverId = process.env.MAILPILOT_SERVER_ID!;
const sentTo = process.env.MAIL_TO!; // address used when the application sent mail
const receivedAfter = new Date().toISOString();
// Trigger the email in your application, then:
const message = await client.messages.waitFor(serverId, {
sentTo,
receivedAfter,
timeout: 30,
});
// Inspect message.subject, message.textBody, message.htmlBody, message.headers
Recommended matching rules
- Use a unique
sentToper test run when tests run in parallel. - Pass
receivedAfter(ISO-8601) so older messages are ignored. - Optionally filter by
subjectwhen the application sets a stable subject line.
REST reference
All paths below are relative to https://api.iqmailpilot.com/api/v1. Replace path parameters and query values with values from your environment.
Wait for a message
curl -s -G "https://api.iqmailpilot.com/api/v1/servers/$MAILPILOT_SERVER_ID/messages/wait" \
--data-urlencode "sentTo=$MAIL_TO" \
--data-urlencode "timeout=30" \
-H "Authorization: Bearer $MAILPILOT_API_KEY"List messages
curl -s "https://api.iqmailpilot.com/api/v1/servers/$MAILPILOT_SERVER_ID/messages?limit=20" \
-H "Authorization: Bearer $MAILPILOT_API_KEY"Get a message
curl -s "https://api.iqmailpilot.com/api/v1/servers/$MAILPILOT_SERVER_ID/messages/$MESSAGE_ID" \
-H "Authorization: Bearer $MAILPILOT_API_KEY"Search messages
curl -s -G "https://api.iqmailpilot.com/api/v1/search/messages" \
--data-urlencode "q=$QUERY" \
-H "Authorization: Bearer $MAILPILOT_API_KEY"Purge a server inbox
curl -s -X POST "https://api.iqmailpilot.com/api/v1/servers/$MAILPILOT_SERVER_ID/purge" \
-H "Authorization: Bearer $MAILPILOT_API_KEY"Endpoints
/serversservers:read/servers/:idservers:read/serversservers:write/servers/:idservers:write/servers/:id/messagesmessages:read/servers/:id/messages/waitmessages:read/servers/:id/messages/:messageIdmessages:read/servers/:id/messages/:messageIdmessages:write/servers/:id/purgemessages:write/search/messagesmessages:read/servers/:id/inboxesinboxes:read/servers/:id/inboxes/generateinboxes:writeInteractive OpenAPI documentation: https://api.iqmailpilot.com/docs
Permission scopes
Scopes apply to API-key authentication only. Dashboard sessions use workspace roles instead.
| Scope | Grants |
|---|---|
servers:read | List and view servers; read SMTP connection metadata (not the password) |
servers:write | Create, update, and delete servers; regenerate SMTP passwords |
messages:read | List, get, wait for, and search messages; download source and attachments |
messages:write | Delete messages; purge a server inbox; send a message from the dashboard |
inboxes:read | List named addresses on a server |
inboxes:write | Create, generate, and delete named addresses |
Minimum for typical CI assertions: servers:read and messages:read. Add messages:write only if the job purges or deletes messages.
Security
- Store API keys and SMTP passwords outside the repository.
- Issue a separate API key per environment or pipeline so revocation is scoped.
- Grant the minimum scopes required for each key.
- Revoke a compromised key from Dashboard → API keys.
- SMTP credentials and API keys are independent. Rotating one does not rotate the other.