---
titel_en: Send mail from your App
titel_nl: Mail versturen vanuit je App
categorie: email
bundels: app, verbruik
geverifieerd_op: 2026-11-25
bewijs: lib/klantdomein-api.ts, lib/klantdomein-sleutel.ts, lib/klantdomein-mail.ts, app/api/mail/route.ts
zoekwoorden: mail, email, e-mail, api, send, versturen, transactional, transactioneel, login link, inloglink, order confirmation, orderbevestiging, password reset, idempotency, smtp, noreply
schakelaar: MAIL_API
---
## en
Your App can send mail itself from the domain of your site: a login link, an order confirmation, a new password. It goes from an address on your own domain, such as `noreply@yourdomain.nl`, so the person who gets it sees your name and not ours.

**Only mail someone asked for.** One mail to one person, because of something they did in your App. No newsletters, no mailing lists, and no mail to people who did not ask for it. Our mail service only allows this kind of mail.

**What you need.** A paid site on the App or Platform plan, with your own domain live and turned on for sending. Is that last part not done yet? Send a ticket and we turn it on. In the portal, on the Agents page of your site, you see which domain your mail goes from and how much you sent.

**The key.** On the same page you create a mail key. You see it once. Put it in your repository as a secret and pass it to your App with the GitHub Action, for example as `MAIL_KEY` in the input `secrets`. Keep it out of your code and out of the browser: whoever has the key can send mail as your site. You can have two keys at a time, so you can switch without failed mail. Create a new key, put it in your App, then revoke the old one.

**Sending.** Send a POST to `https://dorelli.cloud/api/mail`:

```
POST /api/mail
Authorization: Bearer <your mail key>
Content-Type: application/json
Idempotency-Key: order-1234-confirmation

{"from": "orders", "to": "customer@example.com", "subject": "Your order 1234", "text": "Thank you for your order.", "html": "<p>Thank you for your order.</p>"}
```

`from` is only the part before the @. The domain is always that of your site, and you cannot send from another domain. Without `from`, the mail goes from `noreply`. `to` is one address. Send `text`, `html` or both. The whole request is at most 256 KiB. Attachments, cc, bcc and your own headers are not possible.

Send an `Idempotency-Key` with every mail, for example the number of the order. If your App sends the same request again within a day, for example after a timeout, it gets the first answer back and no second mail goes out.

**Limits.** Per site 20 mails an hour, 100 a day and 1,000 a month. We count days and months by the calendar, in UTC. The 1,000 a month are included in your plan, also on Platform, where it does not count as usage and is not on your invoice. Above a limit you get status 429 with the limit and `Retry-After` in the answer, and nothing is sent. If too much of your mail does not arrive, we pause the mail of your site and look at it with you. If our mail service could not take a mail (503), that attempt still counts toward the hour. So during an outage your App tries at most 20 times an hour. Wait for the time in `Retry-After` before you try again.

**Answers.** The answer is JSON. On a refusal, `error` holds a code and `message` says what to do. The portal shows the latest refusals with their code.

| Status | What it means |
|---|---|
| 200 | Sent. |
| 202 | The mail service did not confirm. The mail may have gone, so do not send it again with a new key. |
| 400 | Something in the request is wrong. |
| 401 | No valid mail key. |
| 403 | The site is not active, it is not an App, or its mail is paused. |
| 409 | No domain is ready to send from yet, or a request with the same Idempotency-Key is still running. |
| 413 | Larger than 256 KiB. |
| 422 | The mail service refused this mail, or the Idempotency-Key belongs to another request. |
| 429 | A limit of your site is reached, or the daily limit of the whole platform. |
| 500 | Something went wrong on our side. Nothing was sent. |
| 503 | Try again later. Nothing was sent. |

**What we keep.** Per mail the site, the moment and whether it went. Not the address, the subject or the content. Thirty days. An Idempotency-Key we keep as a hash, for at most 30 hours.

## nl
Je App kan zelf mail versturen vanaf het domein van je site: een inloglink, een orderbevestiging, een nieuw wachtwoord. Hij gaat van een adres op je eigen domein, zoals `noreply@jouwdomein.nl`, dus wie hem krijgt ziet jouw naam en niet de onze.

**Alleen mail waar iemand om vroeg.** Eén mail aan één persoon, omdat die iets deed in je App. Geen nieuwsbrieven, geen mailinglijsten en geen mail aan mensen die er niet om vroegen. Onze maildienst staat alleen dit soort mail toe.

**Wat je nodig hebt.** Een betaalde site op de App- of Platform-bundel, met je eigen domein live en aangezet om vanaf te versturen. Is dat laatste nog niet gedaan? Stuur een ticket, dan zetten we het aan. In het portaal, op de pagina Agents van je site, zie je vanaf welk domein je mail gaat en hoeveel je verstuurde.

**De sleutel.** Op dezelfde pagina maak je een mailsleutel. Je ziet hem één keer. Zet hem als secret in je repository en geef hem met de GitHub Action door aan je App, bijvoorbeeld als `MAIL_KEY` in de input `secrets`. Houd hem buiten je code en buiten de browser: wie de sleutel heeft, kan mail versturen als je site. Je kunt twee sleutels tegelijk hebben, zodat je kunt wisselen zonder dat er mail mislukt. Maak een nieuwe sleutel, zet die in je App en trek daarna de oude in.

**Versturen.** Stuur een POST naar `https://dorelli.cloud/api/mail`:

```
POST /api/mail
Authorization: Bearer <je mailsleutel>
Content-Type: application/json
Idempotency-Key: bestelling-1234-bevestiging

{"from": "bestellingen", "to": "klant@voorbeeld.nl", "subject": "Je bestelling 1234", "text": "Bedankt voor je bestelling.", "html": "<p>Bedankt voor je bestelling.</p>"}
```

`from` is alleen het deel voor de @. Het domein is altijd dat van je site, en vanaf een ander domein versturen kan niet. Zonder `from` gaat de mail van `noreply`. `to` is één adres. Stuur `text`, `html` of allebei. Het hele verzoek is hooguit 256 KiB. Bijlagen, cc, bcc en eigen koppen kunnen niet.

Stuur bij elke mail een `Idempotency-Key` mee, bijvoorbeeld het nummer van de bestelling. Stuurt je App binnen een dag hetzelfde verzoek nog eens, bijvoorbeeld na een time-out, dan krijgt hij het eerste antwoord terug en gaat er geen tweede mail weg.

**Grenzen.** Per site 20 mails per uur, 100 per dag en 1.000 per maand. Dagen en maanden tellen we volgens de kalender, in UTC. Die 1.000 per maand zitten in je bundel, ook op Platform, waar het niet als verbruik telt en niet op je factuur staat. Boven een grens krijg je status 429, met de grens en `Retry-After` in het antwoord, en gaat er niets weg. Komt te veel van je mail niet aan, dan zetten we de mail van je site op pauze en kijken we er samen met je naar. Kon onze maildienst een mail niet aannemen (503), dan telt die poging wel mee in het uur. Bij een storing probeert je App het zo hooguit 20 keer per uur. Wacht de tijd in `Retry-After` af voordat je het opnieuw probeert.

**Antwoorden.** Het antwoord is JSON. Bij een weigering staat in `error` een code en in `message` wat je kunt doen. Het portaal toont de laatste weigeringen met hun code.

| Status | Wat het betekent |
|---|---|
| 200 | Verstuurd. |
| 202 | De maildienst bevestigde het niet. De mail kan weg zijn, dus stuur hem niet nog eens met een nieuwe sleutel. |
| 400 | Er klopt iets niet in het verzoek. |
| 401 | Geen geldige mailsleutel. |
| 403 | De site is niet actief, is geen App, of de mail ervan staat op pauze. |
| 409 | Er staat nog geen domein klaar om vanaf te versturen, of een verzoek met dezelfde Idempotency-Key loopt nog. |
| 413 | Groter dan 256 KiB. |
| 422 | De maildienst weigerde deze mail, of de Idempotency-Key hoort bij een ander verzoek. |
| 429 | Een grens van je site is bereikt, of de daggrens van het hele platform. |
| 500 | Er ging iets mis aan onze kant. Er ging niets weg. |
| 503 | Probeer het later nog eens. Er ging niets weg. |

**Wat we bewaren.** Per mail de site, het moment en of hij wegging. Niet het adres, het onderwerp of de inhoud. Dertig dagen. Een Idempotency-Key bewaren we als hash, hooguit 30 uur.
