Send an email
POST / sends one email with a template: the fields, the defaults and examples.
POST / renders a template with your data and sends it.
Request
curl -H "x-token: YOUR_TOKEN" -H "content-type: application/json" \
-d '{"id":"demo/welcome","to":"jane@example.com","data":{"name":"Jane Doe","plan":"Pro"}}' \
https://mail.example.com/{"success":true}Fields
| Field | Required | Meaning |
|---|---|---|
id | yes | The template identifier: profile/template, for example demo/welcome. |
to | yes | The recipient. Several addresses separated by commas get one email each. |
data | no | An object with the values for the template and the subject, available as value. |
subject | no | Replaces the subject of the template. |
reply | no | A reply address. Replaces Reply to of the profile. |
cc | no | One address that gets a visible copy. |
bcc | no | One address that gets a hidden copy. Replaces BCC of the profile. |
attachments | no | Files to download and attach. See Attachments. |
The sender is always the From address of the profile.
A full example
curl -H "x-token: YOUR_TOKEN" -H "content-type: application/json" -d '{
"id": "demo/welcome",
"to": "jane@example.com",
"cc": "office@example.com",
"bcc": "archive@example.com",
"reply": "sales@example.com",
"subject": "Your account is ready",
"data": { "name": "Jane Doe", "plan": "Pro" }
}' https://mail.example.com/{"success":true}Jane gets the email with the subject "Your account is ready", a copy goes to office@example.com and a hidden copy to archive@example.com, and replies go to sales@example.com.
Several recipients
curl -H "x-token: YOUR_TOKEN" -H "content-type: application/json" \
-d '{"id":"demo/welcome","to":"jane@example.com, john@example.com","data":{"name":"team","plan":"Pro"}}' \
https://mail.example.com/{"success":true}Each address gets its own email; no recipient sees the others. With several recipients, OpenMail answers before the emails are sent, so success does not mean that every email went out. Check Logs, or send one request per recipient when you need the result.
When the answer comes
With one recipient, OpenMail answers after the SMTP server has accepted the email. Give your HTTP client a timeout, for example 30 seconds, so your app does not wait forever if the SMTP server does not respond.