Spanish Total.js
English
Documentation For AI agents
Contents

Send an email

POST / sends one email with a template: the fields, the defaults and examples.

.md GitHub
On this page

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

FieldRequiredMeaning
idyesThe template identifier: profile/template, for example demo/welcome.
toyesThe recipient. Several addresses separated by commas get one email each.
datanoAn object with the values for the template and the subject, available as value.
subjectnoReplaces the subject of the template.
replynoA reply address. Replaces Reply to of the profile.
ccnoOne address that gets a visible copy.
bccnoOne address that gets a hidden copy. Replaces BCC of the profile.
attachmentsnoFiles 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.

Made in Europe