Sending email
Send through the API with POST /v1/emails, or over SMTP from software that already speaks it. Both take the same route inside Postilio: the same checks, limits, suppression list and message log.
Through the API
curl https://api.postilio.eu/v1/emails \
-H "Authorization: Bearer $POSTILIO_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <no-reply@mail.example.com>",
"to": ["ada.lovelace@example.com"],
"subject": "Your sign-in code",
"text": "Your code is 482913.",
"html": "<p>Your code is <b>482913</b>.</p>",
"tag": "sign-in",
"replyTo": "support@example.com"
}'
The key needs the emails:send scope. Examples in Node and C# are in the Quickstart.
| Field | Rules |
|---|---|
from | Required. An address on a verified domain of the project, optionally with a name: Acme <no-reply@mail.example.com>. The name may be in any script. It may not contain ,, @ or a lookalike of @ (the fullwidth @ U+FF20 or the small ﹫ U+FE6B), also not inside an encoded word (=?utf-8?q?…?=): 400 under errors.from, over SMTP too. |
to | Required. 1 to 50 addresses, each a bare address without a name. |
cc, bcc | Optional. Bare addresses, only with exactly one address in to: see Cc and Bcc. |
subject | Required. At most 998 characters, no control characters. |
text, html | At least one of the two. Send both and mail clients pick. |
tag | Optional. Up to 64 letters, digits, - or _; filter on it in the portal and find it in webhook events. |
replyTo | Optional. One address, with or without a name. |
attachments | Optional. Up to 20 files: fileName, contentType (application/pdf), content (base64). One with a contentId is inline: the HTML refers to it as cid: plus that id. |
headers | Optional. Up to 10 headers of your own, such as List-Unsubscribe: see Custom headers. |
sendAt | Optional. When to send it, from a minute to 30 days ahead: see Scheduled sending. |
A message is at most 10 MB, attachments included (413 message_too_large), and its size times the number of recipients at most 25 MB (413 message_too_large_for_recipients): send to fewer recipients at a time then. See Message size for what counts. Everything a request can hold is in the reference.
Attachments
Postilio never sends executable files: an attachment whose fileName ends in .exe, .js, .vbs, .scr, .bat, .cmd, .jar, .iso, .lnk, .hta or .msi refuses the whole message with 422 attachment_type_not_allowed (over SMTP 550 5.7.1 attachment_type_not_allowed), and its message names the file. Mailbox providers such as Gmail refuse them too. Put such a file behind a download link instead.
The answer
202 Accepted means Postilio has stored the message and will deliver it:
{ "ids": ["01a10ce5-a09a-788b-9243-d7c9c59773d2", "01a10ce5-a09a-7dde-9fde-5676dcbd0094"], "suppressed": [] }
Every recipient becomes a message of its own with its own id, in the order of to, then cc, then bcc. A recipient on the project's suppression list is accepted but not sent: it is listed in suppressed and its message gets the status suppressed (see Suppressions).
A request that cannot be sent answers an error and stores nothing; Errors and limits lists them. The common ones: 400 for a field that is not valid, 422 with unverified_sender_domain when the sender's domain is not verified (yet), in the sandbox 422 sandbox_recipient_not_allowed and 429, in the first weeks after it 429 over the probation's cap, 429 over a project's own limit, and 413 for a message that is too large. While Postilio protects its storage it answers 503 service_degraded with a Retry-After: nothing was stored, so send the same request again after that many seconds.
To send safely again after a timeout or a lost answer, add an Idempotency-Key header: see Idempotency.
Cc and Bcc
Every recipient gets a copy of their own, so without cc or bcc a message to several addresses in to shows each recipient only their own address. For a message that people should see was also sent to others, send it to one address in to and add cc, bcc or both:
{
"from": "Acme Support <support@mail.example.com>",
"to": ["ada.lovelace@example.com"],
"cc": ["account-manager@example.com"],
"bcc": ["archive@example.com"],
"subject": "Your ticket 4711",
"text": "Solved: the export works again."
}
- Every copy, the cc and bcc recipients' included, shows
To: ada.lovelace@example.comand theccaddresses inCc:. Abccaddress appears in no header of any copy. ccandbccneed exactly one address into: with more, the answer is422 cc_bcc_require_single_toand nothing is sent.to,ccandbcctogether hold at most 50 addresses, and an address may appear only once over the three (400).- Every recipient is a message of its own, as with
to: its own id (the answer liststo, thencc, thenbcc), its own events and webhooks, and its own check against the suppression list and the sandbox. Each one counts towards your usage and every limit, and towards the size times the recipients (25 MB). - Events and webhooks of a message name its own recipient only; they go to you, never to the other recipients.
Custom headers
headers adds headers of your own to the message, as an object of names and values:
curl https://api.postilio.eu/v1/emails \
-H "Authorization: Bearer $POSTILIO_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <news@mail.example.com>",
"to": ["delivered@simulator.postilio.eu"],
"subject": "What is new in October",
"text": "Three new features. Unsubscribe: https://example.com/unsubscribe/3f9a1c7e",
"tag": "newsletter",
"headers": {
"List-Unsubscribe": "<https://example.com/unsubscribe/3f9a1c7e>, <mailto:unsubscribe@example.com?subject=3f9a1c7e>",
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
"X-Campaign-Id": "october-2026"
}
}'
| Header | Rules |
|---|---|
List-Unsubscribe | One <https://…> URL, one <mailto:…> address, or both, separated by a comma; at most 512 characters. The URL must be on a public host name or address, without a user name, password or fragment. |
List-Unsubscribe-Post | Only List-Unsubscribe=One-Click, and only together with an https URL in List-Unsubscribe (one-click unsubscribe, RFC 8058). |
In-Reply-To, References | One or more message ids such as <4711@mail.example.com>, separated by a space: they place the message in a conversation. |
X-… | X- and up to 62 letters, digits or -, such as X-Campaign-Id. Not X-Postilio-…, X-Tenant or X-Kumo…. |
- At most 10 headers. A name may appear once; names are not case-sensitive.
- Every value is 1 to 900 printable ASCII characters on one line: no line breaks, control characters or accented letters.
- Any other header cannot be set, so none of the headers Postilio writes itself can be replaced:
From,To,Cc,Bcc,Subject,Date,Message-ID,MIME-Version,Content-…,DKIM-Signature,Feedback-ID,ReceivedandReturn-Path. Use the fieldsfrom,to,subjectandreplyToinstead. - A header that breaks a rule answers
400with the reason undererrors.headers, and nothing is sent. - Headers count towards the message size of 10 MB.
- The DKIM signature covers
List-Unsubscribe,List-Unsubscribe-Post,In-Reply-ToandReferences, so a mailbox provider can trust them;X-headers are passed on unsigned. - Every recipient's message gets the same headers. Postilio does not change them, and does not act on them: an unsubscribe goes to your URL or address, and you stop sending. To have Postilio refuse an address from then on, add it to the suppression list.
What recipients see
Besides your own headers, every message carries:
- Two DKIM signatures. One with
d=your domain, which DMARC aligns on (see Domains), and one withd=outbound.postilio.eu, Postilio's own. The second one changes nothing for DMARC; it lets the large mailbox providers report spam complaints about all mail sent through Postilio to Postilio (Yahoo's complaint feedback loop, Gmail's Postmaster Tools), so a sender that draws complaints is found early. As Postilio moves its infrastructure topstlmta.net, a third signature withd=pstlmta.netmay join these two, for the same reason; it changes nothing for DMARC either. - A
Feedback-IDheader, such asFeedback-ID: 3f1c2a9b7d04:9e8a61c05b2f:tx:postilio, signed by the second signature. The first two parts stand for your project and your organization: short hashes, without names. Gmail counts complaints per part, never per recipient. - A return path (the envelope sender) like
b-<message id>-<key><code>@pst-bounces.<domain>(@bounce.<domain>for domains added before that name), one per message and recipient. The code is a signature: only Postilio can make one, so a bounce to it is known to be about that message, and a forged one is ignored. Bounces to it are taken for 30 days.
Unsubscribe and the large mailbox providers
Gmail and Yahoo ask bulk senders (Gmail: about 5,000 messages a day or more to Gmail addresses) for one-click unsubscribe on marketing and subscribed mail: a List-Unsubscribe with an https URL plus List-Unsubscribe-Post: List-Unsubscribe=One-Click, both DKIM-signed, and a visible unsubscribe link in the message. A mailto: alone does not meet Gmail's requirement. Unsubscribes must be honoured within two days. Transactional mail is exempt: sign-in codes, password resets, receipts and order confirmations need no List-Unsubscribe. Since November 2025 Gmail rejects more non-compliant mail.
For one-click, your URL takes a POST with the body List-Unsubscribe=One-Click, answers without a redirect, and needs no cookie or login: put a hard-to-guess token for the recipient in the URL itself. Sources, read on 2026-10-07: Gmail sender guidelines and FAQ, Yahoo sender requirements, RFC 8058.
Scheduled sending
Add sendAt and the message waits until then, with the status scheduled:
# An hour from now, in UTC (GNU date; on macOS: date -u -v+1H +%Y-%m-%dT%H:%M:%SZ).
SEND_AT=$(date -u -d '+1 hour' +%Y-%m-%dT%H:%M:%SZ)
curl https://api.postilio.eu/v1/emails \
-H "Authorization: Bearer $POSTILIO_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <no-reply@mail.example.com>",
"to": ["ada.lovelace@example.com"],
"subject": "Your trial ends tomorrow",
"text": "Your trial of Acme ends tomorrow at noon.",
"tag": "trial-reminder",
"sendAt": "'"$SEND_AT"'"
}'
sendAt is an ISO 8601 date and time with Z (UTC) or an offset, such as 2026-11-02T09:00:00+01:00. Without either, the time would be in nobody's zone in particular, so it is refused with a 400 under errors.sendAt. It is at least a minute and at most 30 days ahead (422 send_at_too_soon, 422 send_at_too_far). Postilio hands the message to its mail server at that time; with many messages due at once, it can take a little longer.
Until it goes out you can cancel it (scope emails:send):
curl -X DELETE https://api.postilio.eu/v1/emails/$EMAIL_ID \
-H "Authorization: Bearer $POSTILIO_KEY" \
-w "%{http_code}\n"
204 means it will not be sent: it gets the status canceled, a canceled event with the reason canceled_by_request, and its content is deleted. Once it is on its way, or for a message that was not scheduled, the answer is 409 email_not_scheduled. Changing a scheduled message is cancelling it and sending a new one.
What is checked when:
- When you send the request, as for any message: the fields, the sender's domain, the sandbox, the suppression list, the size and the storage protection. A project holds at most 10,000 scheduled messages, together at most 256 MB (
409 scheduled_limit_reached,409 scheduled_size_limit_reached). - When it is due, again: the suppression list, the sender's domain and the sandbox. A message that may not go any more ends as
canceled, with the reasonunverified_sender_domainorsandbox_recipient_not_allowed. A suspended or paused project sends nothing until it is resumed; a message still waiting a day after itssendAtexpires. - Limits and usage count when it is due, not when you schedule it: a message scheduled for next month counts in next month. When a per-minute limit is full, it waits for the next minute. When a daily or monthly limit is reached (the plan's, the project's or the platform's), it is not sent: it ends as
canceledwith the limit's code as the reason, such asplan_monthly_limit_reached(see Errors and limits), and a webhook tells you.
cc, bcc and headers work with sendAt as without. An Idempotency-Key with the same sendAt (the same moment, in any notation) answers with the same messages; with another sendAt it is a different request (409 idempotency_key_reused_with_different_request). A test key checks sendAt but simulates the message at once. Scheduling is for the API only: SMTP has no way to say when.
What happens next
Each message moves through these statuses. A status only moves forward, so events that arrive late do not move a message back; a bounce or a complaint after a delivery still wins.
| Status | Meaning |
|---|---|
accepted | stored, waiting to be handed to the mail server |
scheduled | stored, waiting for its sendAt |
canceled | not sent: canceled while scheduled, or no longer allowed when it was due (see reason) |
queued | handed to the mail server |
deferred | not delivered yet (the receiving server refused it for now, or could not be reached); it is tried again |
delivered | the receiving server accepted it |
bounced | refused for good, also when the bounce arrives after a delivery |
expired | not delivered within a day; no more attempts |
complained | the recipient marked it as spam |
suppressed | not sent, because the address is on the suppression list |
Look a message up with GET /v1/emails/{id} (scope emails:read):
curl https://api.postilio.eu/v1/emails/$EMAIL_ID \
-H "Authorization: Bearer $POSTILIO_KEY"
{
"id": "01a10ce5-a09a-788b-9243-d7c9c59773d2",
"status": "bounced",
"from": "no-reply@mail.example.com",
"to": "bounced@simulator.postilio.eu",
"subject": "Welcome to Acme",
"tag": "welcome",
"acceptedAt": "2026-10-05T16:28:57.882+00:00",
"test": true,
"via": "api",
"events": [
{ "type": "accepted", "occurredAt": "2026-10-05T16:28:57.882+00:00", "smtpCode": null, "response": null, "attempt": null, "remoteHost": null, "enhancedCode": null, "classification": null, "reason": null, "async": null },
{ "type": "queued", "occurredAt": "2026-10-05T16:28:57.882+00:00", "smtpCode": null, "response": null, "attempt": null, "remoteHost": null, "enhancedCode": null, "classification": null, "reason": null, "async": null },
{ "type": "bounced", "occurredAt": "2026-10-05T16:28:57.882+00:00", "smtpCode": 550, "response": "550 5.1.1 Simulated: the mailbox does not exist", "attempt": 1, "remoteHost": "mx.simulator.postilio.eu", "enhancedCode": "5.1.1", "classification": "InvalidRecipient", "reason": "recipient_rejected", "async": null }
]
}
via is how the message came in: api, smtp, or test_mail for a test email. subject is null when the project does not keep subjects. The message log keeps no bodies or attachments. What reason, response and the codes of an event mean: Delivery status and reasons. To hear about events as they happen instead of asking, use Webhooks.
SMTP
For software that sends mail over SMTP: point it at Postilio and log in with an API key.
| Setting | Value |
|---|---|
| Host | smtp.postilio.eu |
| Port | 587 with STARTTLS (recommended), or 465 with TLS from the first byte |
| User name | apikey |
| Password | an API key with the emails:send scope |
Port 25 is not used: it is for traffic between mail servers, not for submitting mail. TLS 1.2 or 1.3 is required, and a login is accepted only after TLS is up. The host answers over IPv4 and IPv6, and sees your own address over both: a key limited to networks (Restrictions) works over SMTP with IPv6 networks too.
With curl (for 465, use smtps://smtp.postilio.eu:465 without --ssl-reqd):
cat > welcome.eml <<'MAIL'
From: Acme <no-reply@mail.example.com>
To: delivered@simulator.postilio.eu
Subject: Welcome to Acme
Hi Ada, your account is ready.
MAIL
curl smtp://smtp.postilio.eu:587 --ssl-reqd \
--user "apikey:$POSTILIO_KEY" \
--mail-from no-reply@mail.example.com \
--mail-rcpt delivered@simulator.postilio.eu \
--upload-file welcome.eml
In C#, with System.Net.Mail:
// Sends an email over SMTP submission: dotnet run SmtpSend.cs (.NET 10, no packages needed).
// System.Net.Mail speaks STARTTLS (port 587) only; for TLS on port 465 use a library such as MailKit.
using System.Net;
using System.Net.Mail;
using var smtp = new SmtpClient("smtp.postilio.eu", 587)
{
EnableSsl = true, // STARTTLS, before the login
Credentials = new NetworkCredential("apikey", Environment.GetEnvironmentVariable("POSTILIO_KEY")),
};
using var message = new MailMessage("Acme <no-reply@mail.example.com>", "delivered@simulator.postilio.eu",
"Welcome to Acme", "Hi Ada, your account is ready.");
await smtp.SendMailAsync(message);
Console.WriteLine("Accepted");
In Node, with nodemailer:
// Sends an email over SMTP submission with nodemailer: npm install nodemailer, then node smtp.mjs.
import nodemailer from 'nodemailer';
const transport = nodemailer.createTransport({
host: 'smtp.postilio.eu',
port: 587, // STARTTLS; for port 465 set secure: true
secure: false,
requireTLS: true,
auth: { user: 'apikey', pass: process.env.POSTILIO_KEY },
});
const info = await transport.sendMail({
from: 'Acme <no-reply@mail.example.com>',
to: 'delivered@simulator.postilio.eu',
subject: 'Welcome to Acme',
text: 'Hi Ada, your account is ready.',
});
console.log(info.response); // 250 2.0.0 Ok: queued as <id>
How a message is read
- The envelope decides the recipients (
RCPT TO): theToandCcheaders add no one, and aBccheader is never passed on. - When the
Toheader holds exactly one address and that address is a recipient, the message is read as the API's Cc and Bcc: every copy shows thatToand theCcheader's recipients, and every other recipient is a bcc. Otherwise (severalToaddresses, aCcaddress that is not a recipient,undisclosed-recipients:;) every recipient gets a copy of its own that shows only their own address, as before. - The
Fromheader must hold exactly one address. It, and the envelope sender (MAIL FROM), must be on a verified domain of the key's project. - The first plain-text part and the first HTML part are the bodies; every other part is an attachment, inline when it has a
Content-ID.Reply-Tois kept; a tag cannot be set over SMTP. List-Unsubscribe,List-Unsubscribe-Post,In-Reply-To,ReferencesandX-headers are kept when they follow the rules of custom headers. One that does not is left out and the message is still sent, so a mail client's ownX-headers never stop a message; check aList-Unsubscribewith the API first if you rely on it. Every other header, and aBccheader, is not passed on.- The answer to the message names the id of the first recipient's message:
250 2.0.0 Ok: queued as <id>, followed byand 2 morefor more recipients and; 1 suppressed recipient(s) not sentwhen some are on the suppression list. - A client that sends a message again with the same
Message-IDto the same recipients within 24 hours does not send it twice (see Idempotency).
Limits and replies
| Limit | Reply |
|---|---|
10 MB per message, as sent (SIZE in the EHLO answer): over it at MAIL FROM with SIZE= | 552 |
| … or as soon as the message outgrows it, after which the connection is closed | 552 5.3.4 message_too_large |
| 50 recipients per message: the rest go in a next message | 452 4.5.3 |
The size times the recipients at most 25 MB: with SIZE= the recipient over it, and the rest, go in a next message; without, the message after DATA | 452 4.5.3 at RCPT TO, or 552 5.3.4 message_too_large_for_recipients |
| 20 messages per connection: reconnect for more | 421 4.7.0 |
| 600 messages per key per minute | 451 4.7.1 |
| 10 connections at once from one address (over IPv6: one /64), of which 5 not logged in yet | the connection is closed |
| 10 failed logins per 15 minutes from one address (over IPv6: one /64): wait | 454 4.7.0 |
| Log in within 15 seconds of connecting, the TLS handshake included, and do not stay silent for more than 10 seconds before you do | the connection is closed |
| Many connections at once that do not log in: Postilio keeps room for them, and when it is full a new connection closes the one that has waited longest without logging in. A client that logs in right after connecting is not affected | the connection is closed |
| Reply | Why |
|---|---|
535 5.7.1 client_ip_not_allowed | the key is restricted to other networks |
535 5.7.1 insufficient_scope | the key lacks emails:send |
553 5.7.1 unverified_sender_domain | the envelope sender's domain is not verified (at MAIL FROM) |
550 5.7.1 unverified_sender_domain | the From header's domain is not verified (after the message) |
553 5.7.1 or 550 5.7.1 sender_domain_not_allowed_for_key | the key may not send from that domain (envelope or From header) |
550 5.7.1 sandbox_recipient_not_allowed | in the sandbox, a recipient outside your team and verified domains |
451 4.7.1 sandbox_daily_limit_reached, sandbox_rate_limit_reached | a sandbox limit; a mail server tries again later |
451 4.7.1 probation_daily_limit_reached, probation_rate_limit_reached | the cap of the probation after the sandbox; a mail server tries again later |
451 4.7.1 project_daily_limit_reached, project_rate_limit_reached | the project's own limit, see Project limits; a mail server tries again later |
451 4.7.1 plan_monthly_limit_reached, plan_daily_limit_reached, plan_rate_limit_reached | a limit of your plan, see Plan limits; a mail server tries again later |
451 4.7.1 platform_rate_limit_reached, platform_daily_limit_reached | the platform's safety limit per key or project, or on a project's test keys, see Platform limits; a mail server tries again later |
554 5.6.0 | the message is not valid: not MIME, no single From address, or a field the API would refuse (the reply names it) |
550 5.7.1 attachment_type_not_allowed | an attachment is an executable file, see Attachments (the reply names it) |
554 5.6.0 message_id_reused_with_different_content | the same Message-ID with other content within 24 hours |
554 5.7.1 organization_suspended | Postilio suspended your organization; the connection is closed |
554 5.7.1 project_suspended | the key's project is paused or suspended, see Paused projects; the connection is closed |
530 5.7.0 | the key was revoked during the session |
530 5.7.1 client_ip_not_allowed, 530 5.7.1 insufficient_scope | the key was changed during the session and may no longer send from here; the connection is closed |
452 4.3.1 service_degraded | Postilio takes no new messages for now, to protect its storage; a mail server tries again later |
451 4.3.0, 451 4.3.2 | a temporary failure at Postilio, or busy; try again |