Send email over HTTPS
Send a test message from the Send tab, then send from your application with the send API and an API key.
In the dashboard
The send API takes a message as JSON over HTTPS and hands it to SMTP Relay, which signs it for your domain and delivers it as it does mail sent over SMTP. Use it where an SMTP connection is awkward, such as in a serverless function. Before you wire up an application, you can check a domain end to end by sending a test message from the Send tab.
Before you begin
Section titled Before you begin- A verified sending domain on the relay. Over SMTP a domain can send once its ownership check passes, but the send API waits until the domain shows
Verified. See Add a sending domain to SMTP Relay. - At least one SMTP credential on the relay. The send API submits each message with one: a credential on the From address's domain when there is one, otherwise any active credential on the relay.
- A send API key for the application. The Send tab does not need one.
Send a test message from the dashboard
Section titled Send a test message from the dashboard- In the dashboard, go to Email, open the SMTP Relay service, then the Send tab.
- In From, enter the part of the address before the @, such as
no-reply, and choose a verified domain after it. - Optionally, enter a From name, such as
Example Billing. - In To, enter up to 50 addresses, separated by commas or spaces.
- Enter a Subject and a Message. The message is plain text.
- In Category, leave Service default or choose Transactional or Marketing. See Transactional and marketing mail.
- Select Send message.
A toast says Accepted for 1 recipient., and a green Accepted for delivery box links to the Events tab, where you can watch the message arrive. The test message counts towards the month's allowance like any other. When the relay refuses the message, a Could not send the message box shows one of the messages in Troubleshooting.
Send from your application
Section titled Send from your applicationPost the message to /mail/send with the key in the X-Api-Key header:
curl -X POST https://api.coritan.com/api/v1/mail/send \
-H "X-Api-Key: $MAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "receipts@example.com",
"from_name": "Example Billing",
"to": ["alex@example.com"],
"subject": "Your receipt",
"text": "Thanks for your order.",
"html": "<p>Thanks for your order.</p>",
"category": "transactional"
}'
The dashboard's API keys tab shows the same endpoint on www.coritan.com. Both hosts answer it.
The body takes these fields. Only from, to and one of text or html are needed:
from- The sender's address, 3–320 characters, on a verified domain of the relay. It is used as the envelope sender too.
from_addressis accepted as another name for it. from_name- Optional, up to 255 characters. The name shown next to the address.
to- A list of 1–50 addresses.
cc- Optional, a list of up to 50 addresses. A transactional message takes 50 recipients across
toandcctogether. subject- Optional, up to 998 characters. Empty when left out.
text- The plain-text body, up to 5,000,000 characters.
html- The HTML body, up to 10,000,000 characters. With
textas well, the message carries both and the recipient's app picks one. reply_to- Optional, up to 320 characters. The address replies go to.
headers- Optional, an object of extra headers, such as
{"X-Order-Id": "10492"}. Only headers whose names start withX-, plusList-Unsubscribe,List-Unsubscribe-Post,List-IdandPrecedence, are added; any other header is dropped without an error. A name can have up to 64 characters and a value is cut at 998. category- Optional,
transactionalormarketing. Left out, the message takes the relay's default category.
The send API has no field for attachments or blind copies, and it ignores fields it does not know, such as bcc or attachments. To send either, use SMTP. The whole message, as built, can be up to 25 MB.
We add Date, a Message-ID at your domain and an X-Mail-Category header that names the category we sent the message as.
Read the answer
Section titled Read the answerThe answer is 202: we accepted the message and queued it for delivery. It does not mean the message has arrived. Follow it on the Events tab or with webhooks.
A transactional message answers with the addresses we sent it to:
{
"accepted": ["alex@example.com"],
"suppressed": [],
"node": "mx1.mail-fra.coritan.com",
"message_id": "<175890432171.2481.9311874401294517206@example.com>"
}
accepted- The recipients we queued the message for.
suppressed- The recipients we left out because they are on the relay's suppression list. When every recipient is suppressed, nothing is sent,
acceptedis empty andnodeisnull, and the answer is still202. node- The name of the mail server that took the message.
message_id- The message's
Message-IDheader. Webhook events and receiving servers refer to the message by it.
Send marketing mail
Section titled Send marketing mailWith "category": "marketing", or no category on a relay whose default is marketing, the send API sends each address in to and cc its own copy, addressed to that person alone. Each copy carries List-Unsubscribe and List-Unsubscribe-Post headers with a link for that recipient, so receiving apps can show an unsubscribe button. Transactional and marketing mail explains what an unsubscribe does.
The answer counts the copies and lists each one:
{
"accepted": 2,
"category": "marketing",
"messages": [
{
"accepted": ["alex@example.com"],
"suppressed": [],
"node": "mx1.mail-fra.coritan.com",
"message_id": "<175890432171.2481.9311874401294517206@example.com>"
},
{
"accepted": ["sam@example.com"],
"suppressed": [],
"node": "mx1.mail-fra.coritan.com",
"message_id": "<175890432172.2481.5170284763319902451@example.com>"
}
]
}
Here accepted is a number, the copies we queued, where a transactional answer gives a list of addresses. A copy to a suppressed address appears in messages with an empty accepted and is not counted.
Check your limits
Section titled Check your limitsRead what the relay may still send with the same key:
curl https://api.coritan.com/api/v1/mail/send/limits \
-H "X-Api-Key: $MAIL_API_KEY"
The answer holds the relay's allowance and hourly limit, which How SMTP Relay sending limits work describes field by field, and three more fields:
sending_frozentruewhile sending is paused for the relay.max_recipients50, the most recipients one request can have.max_message_bytes26214400, the largest message the send API builds, in bytes (25 MB).
Check remaining before a large batch: it is null when the relay has no monthly cap.
Troubleshooting
Section titled Troubleshooting401X-Api-Key header required- The request has no
X-Api-Keyheader. The send API does not readAuthorization. 401Invalid API key- The key is wrong or revoked, or the relay is not active. See Create and revoke send API keys.
403API key cannot send- The key does not have the
sendability. Keys you create on the API keys tab always have it, so create a new key. 422with adetaillist- A field is missing or out of range: no
fromorto, more than 50 addresses intoorcc, or acategoryother thantransactionalormarketing. Each item indetailnames the field inloc. 400Provide a text or html body- Add
text,htmlor both. 400At most 50 recipients per message- A transactional message has more than 50 addresses in
toandcctogether. Split it into several requests. 400Message exceeds 25 MB- Shorten the message, or link to large content instead of putting it in the body.
400example.org is not a domain on this service- The domain of
fromis not on the relay. Use an address on one of the relay's domains, or add the domain. A subdomain is a domain of its own: with onlysend.example.comon the relay, send from an address atsend.example.com. Over SMTP, the From header can useexample.comwhen your account also holds that domain, in Coritan DNS or on another mail service; the send API cannot. 400example.com is not verified yet; publish its DNS records first- The domain is on the relay but not verified. Publish its records and verify it.
400Create an SMTP credential on this service before sending through the API- The relay has no active SMTP credential. Create one, or turn one back on.
400Sending is paused on this service; contact support- Sending is paused for the relay. See Sending reputation and deliverability.
429Monthly allowance and its 12% buffer are used up; upgrade the plan to continue- Sending the request would take the relay past everything its plan allows this month. A free plan says
Monthly sending allowance reached; upgrade the plan to continue. See How SMTP Relay sending limits work. 400Rejected by mail engine:followed by an SMTP reply- The relay's mail server refused the message, and the reply after the colon says why. The replies it can give are listed under SMTP credentials.
400No mail node is available right nowor400All mail nodes refused the connection:- We could not reach a mail server to take the message. Nothing was sent, so retry the request after a short wait.
503Mail service unavailable- The relay's service could not be found on our side. Contact support if it persists.
Related
Section titled Related- Create and revoke send API keys
- Transactional and marketing mail
- Look up message events
- Mail Send API reference
With the API
Section titled With the APIThe Send tab posts to /client/smtp-relay/{service_id}/messages, which takes the same body and gives the same answers with an access token in place of an API key:
curl -X POST https://api.coritan.com/api/v1/client/smtp-relay/4812/messages \
-H "Authorization: Bearer $CORITAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"from": "no-reply@example.com", "to": ["alex@example.com"], "subject": "Test", "text": "Hello from SMTP Relay."}'
It answers 202 as above. A relay that is not active answers 409 Service is not active.
On a Mail Hosting service, POST /client/mail/{service_id}/messages answers 404 Not an SMTP Relay service. Mailboxes send through a mail app or webmail.
API operations on this page
| Method | Path | What it does |
|---|---|---|
POST | /api/v1/mail/send | Send |
GET | /api/v1/mail/send/limits | Limits |
POST | /api/v1/client/smtp-relay/{service_id}/messages | Send message |
POST | /api/v1/client/mail/{service_id}/messages | Send message |