SMTP Servers
Configure one or more SMTP servers for email delivery. Posta routes emails through your configured SMTP servers.
For the full request/response schema, see the interactive API Reference at /docs on your Posta instance.
Adding an SMTP Server
POST /api/v1/workspaces/current/smtp-servers
curl -X POST http://localhost:9000/api/v1/workspaces/current/smtp-servers \
-H "Authorization: Bearer <jwt>" \
-H "X-Posta-Workspace-Id: 1" \
-H "Content-Type: application/json" \
-d '{
"name": "Transactional",
"host": "smtp.gmail.com",
"port": 587,
"username": "your-email@gmail.com",
"password": "your-app-password",
"encryption": "starttls",
"max_retries": 3,
"allowed_emails": ["noreply@yourdomain.com", "alerts@yourdomain.com"]
}'
name is optional, up to 100 characters. The dashboard shows it instead of the host, which tells apart several servers on the same host.
Encryption Options
| Value | Port | Description |
|---|---|---|
none | 25 | No encryption (not recommended) |
starttls | 587 | Upgrade to TLS after connecting |
ssl | 465 | TLS from the start |
Testing Connections
Verify SMTP credentials and connectivity before sending via POST /api/v1/workspaces/current/smtp-servers/{id}/test. This validates the hostname, port, credentials, and encryption.
Sender Restrictions
Use allowed_emails to restrict which sender addresses can use a specific SMTP server. This is useful when different servers are configured for different brands or departments.
When a workspace has several enabled SMTP servers, Posta picks one per email from its sender address:
- A server whose
allowed_emailscontains the sender (compared case-insensitively). - Otherwise, a server with an empty
allowed_emailslist, which accepts any sender. - Otherwise, the email fails with
no SMTP server allows sender "...".
When several servers qualify at the same step, priority and weight decide between them (see below).
The shared servers an operator configures are used only when the workspace has no enabled SMTP server of its own.
To see which servers an address would use, in order, and why the others are left out:
curl "http://localhost:9000/api/v1/workspaces/current/smtp-servers/resolve?sender=billing@yourdomain.com" \
-H "Authorization: Bearer <jwt>" \
-H "X-Posta-Workspace-Id: 1"
{
"success": true,
"data": {
"sender": "billing@yourdomain.com",
"candidates": [
{"id": 3, "name": "Billing", "host": "smtp.example.com", "priority": 0, "weight": 1, "match": "listed"},
{"id": 4, "name": "Backup", "host": "smtp2.example.com", "priority": 10, "weight": 1, "match": "any_sender", "paused_until": "2026-12-05T18:53:00Z"}
],
"skipped": [
{"id": 5, "name": "Alerts", "host": "smtp.example.com", "reason": "sender_not_allowed"}
]
}
}
match is listed when the server's allowed_emails names the sender and any_sender when its list is empty. A skipped server's reason is disabled, invalid (its connection test fails) or sender_not_allowed. When no server would send, problem is no_enabled_server or sender_not_allowed. Servers of the same priority and match are drawn by weight for each email, so their order in a real send can differ from this one. The Which server sends as box on the SMTP Servers page runs this check.
Priority and Weight
Each server has a priority (0-1000, default 0) and a weight (1-100, default 1), set when you add or edit it.
- Priority works like MX records: a lower value is tried first. Give backup servers a higher number, and they only send when every server with a lower number is paused or fails.
- Weight shares traffic between servers with the same priority, in proportion. Weights
3and1send about 75% of emails through the first server and 25% through the second. Each email draws its order at random, so the split holds over many emails, not for each one.
Priority and weight apply within each step above: a server that lists the sender always comes before a catch-all server, whatever their priorities. Servers with the same priority and weight split traffic evenly; existing servers start at priority 0 and weight 1.
curl -X PUT http://localhost:9000/api/v1/workspaces/current/smtp-servers/3 \
-H "Authorization: Bearer <jwt>" \
-H "X-Posta-Workspace-Id: 1" \
-H "Content-Type: application/json" \
-d '{"priority": 10, "weight": 1}'
Fault Isolation
A failing SMTP server does not hold up mail that another server can send. When a send fails because of the server itself (it cannot be reached, TLS or authentication fails, or it answers 421), Posta records the failure and tries the next server allowed for that sender, in the order above: another server of the same priority first, then the next priority. A rejection of the message itself, such as 550 user unknown, is not a server fault: it does not move the email to another server.
After 3 server faults in a row, the server is paused for 5 minutes and left out of selection. Once the pause ends, the next email tries it again: a success clears the failure count, and another fault pauses it again. A passing Test Connection also clears it. The dashboard shows a paused server with a Paused badge, and its detail page shows when the pause ends and the last error.
When every server allowed for a sender is paused, queued emails stay queued and are retried later without using up their retries.
Pausing is separate from the Enabled/Disabled status: a paused server needs no action to come back.
Sending Statistics
Posta counts every send attempt per SMTP server and per day (UTC):
| Counter | Meaning |
|---|---|
sent | The server accepted the email. |
rejected | The server refused this message, for example 550 user unknown. |
faults | The server itself failed: connection, TLS or login failure, or 421. Each fault on a server that failover moved past counts here too. |
The success rate is sent divided by all attempts. The counters are kept separately from the email log, so they stay when old emails are cleaned up, and are deleted with the server.
Each server on the SMTP Servers page shows its sent count, success rate, faults and a daily chart for the last 30 days. A server's detail page shows its totals, last send and a daily chart for 7, 30 or 90 days.
Through the API:
# Totals and daily counts for every SMTP server of the workspace
curl "http://localhost:9000/api/v1/workspaces/current/smtp-servers/stats?days=30" \
-H "Authorization: Bearer <jwt>" \
-H "X-Posta-Workspace-Id: 1"
# Totals and a daily series for one server
curl "http://localhost:9000/api/v1/workspaces/current/smtp-servers/3/stats?days=7" \
-H "Authorization: Bearer <jwt>" \
-H "X-Posta-Workspace-Id: 1"
days covers today and the days before it, from 1 to 365 (default 30). The summary also takes from and to dates (YYYY-MM-DD, UTC) for a fixed range, as the analytics page uses, in place of days.
The SMTP Servers page groups servers by priority, shows how weight splits mail between servers of the same priority and sender rule, and keeps disabled servers in a collapsed list at the bottom.
Passwords are never returned in API responses.
Common SMTP Providers
| Provider | Host | Port | Encryption |
|---|---|---|---|
| Gmail | smtp.gmail.com | 587 | starttls |
| Outlook | smtp.office365.com | 587 | starttls |
| Amazon SES | email-smtp.us-east-1.amazonaws.com | 587 | starttls |
| Mailgun | smtp.mailgun.org | 587 | starttls |
| Postfix (local) | localhost | 25 | none |