# Send app emails.

Your app sends emails like receipts and password resets. This page shows how to set that up in Outbox Stack, one step at a time. You do not need to be a developer for most of it.

## What an app email is

An app email is one message your app sends to one person because that person did something. People in email call this transactional email. Some examples are below.

| Email | What caused it |
| --- | --- |
| Receipt | A customer paid you. |
| Password reset | Someone asked to reset their password. |
| Sign-in code | Someone tried to sign in. |
| Alert | Something happened in an account, such as a new login or a failed payment. |

Your app sends these through the Outbox Stack API. An API is a way for one program to talk to another, so your app asks Outbox Stack to send the email and Outbox Stack delivers it.

**Not for newsletters**A newsletter or an announcement goes to a whole list of people at once. That is marketing email, and it needs an unsubscribe link and other protections. Do not send it through the API. [Read how to send newsletters](https://outboxstack.app/docs/send-newsletters).

## Before you start

Check that you have these before you begin.

| You need | Why |
| --- | --- |
| A verified account | You signed up and clicked the link in the email we sent you. You also need the admin role in your workspace to set up sending and create keys. |
| A domain you control | A domain is the part of an address after the @, such as yourcompany.com. Your emails come from an address at this domain. |
| Access to its DNS | DNS is the public settings list for your domain. You add a few lines to it, called records. You change them where you bought the domain or where it is hosted, such as Cloudflare, Namecheap or GoDaddy. If someone else manages it, you can send them the records. |
| 15 to 30 minutes | Most of that time is waiting for your domain records to be found. |

**No domain yet?** Your developer can still build and test. A test key accepts emails, checks them and records them, but delivers nothing. It works before you set up sending or add a domain. [Read about test mode](https://outboxstack.app/docs#test-mode).

With managed sending, you can also send a test from our sandbox address while your domain is not ready. The sandbox address only sends to people in your workspace, and at most 50 emails a day.

## Set it up step by step

Each step names the page to open in the dashboard sidebar. Each step ends with a check that shows it worked.

1.  **Choose who delivers your email.** Open **Sending providers**. A provider is the service that delivers your email. If you have no email provider account, choose **Set up managed sending**, answer the questions and choose **Turn on managed sending**. If you already pay for Amazon SES, Cloudflare Email, ZeptoMail or an SMTP server, choose **Connect your own provider** instead, then choose **Use for transactional email** on its card. Not sure? [Read how to choose](https://outboxstack.app/docs/choose-setup#who-delivers). **How you know it worked.** The provider's card shows **Sends transactional email**, and no warning about a missing provider for transactional email shows above the cards.
2.  **Add and verify your domain.** Open **Domains**, choose **Add a domain**, type your domain and choose **Get my DNS records**. Add each record it shows at your DNS host. The next section explains them. Then choose **Check now**. The page also checks by itself every few seconds while it is open. If someone else runs your DNS, choose **Copy instructions for your IT person** and send them the text. **How you know it worked.** The domain's status shows **Ready to send** and the page says you can send from any address at your domain.
3.  **Create a key for your app.** Open **API keys & SMTP**. An API key is a long secret password that lets your app send email from your workspace. Under **Create an API key**, give it a name such as Production server, set **Access** to **Sending only (recommended)** and choose **Create key**. A sending only key can send and read messages, nothing else, so a leaked key does less harm. The key is shown once. Copy it straight into a safe place your developer can reach, such as a password manager. **How you know it worked.** The key appears under **Your keys** with access **Sending**.
4.  **Send a test.** Open **Email activity** and choose **Send a test email**. Send it to your own address, from an address at your verified domain, then choose **Send test email**. **How you know it worked.** The email arrives in your inbox, and its row on **Email activity** shows **Delivered**.

With Cloudflare Email, ZeptoMail or an SMTP server, you verify your domain in that provider's own dashboard, not on **Domains**. Follow your provider's steps, then carry on from step 3.

**How to tell setup is done**The **Overview** page has a setup checklist. For app email, four steps matter. They are **Choose how you send**, **Verify your sending domain**, **Connect your app** and **Send a test email**. When all four are ticked, you are ready. [See when each step counts as done](https://outboxstack.app/docs/choose-setup#ready).

## Your domain records, explained

Anyone can put any address in the From line of an email. Inboxes like Gmail and Outlook check your domain's records to decide if an email really came from you. Without them, your emails land in spam or get refused. The domain page groups your records under the headings below.

| Heading on the page | Record type | What it does |
| --- | --- | --- |
| Account ownership | TXT | Proves the domain belongs to you. Shown for managed sending only. A TXT record is a line of plain text stored on your domain. |
| Domain verification | TXT or CNAME | Sets up DKIM. DKIM adds a signature to each email so inboxes can tell it came from you and was not changed on the way. Keep these records for as long as you send through Outbox Stack. |
| Bounce handling · SPF | MX and TXT | Recommended. A bounce is an email that could not be delivered. These records send bounce reports back through a bounce address on your domain. The TXT record is SPF, a list of who may send email for that address. Both sit on a subdomain such as bounce.yourcompany.com. |
| DMARC policy | TXT | DMARC tells inboxes what to do with an email that fails the checks above. If you already have a valid DMARC record, keep it. |

Copy each record's **Name / Host** and **Value** with the copy buttons. In most DNS panels you type only the Name/Host part, and the panel adds your domain itself.

### Where to add them

-   **Cloudflare.** The domain page may offer to add the records for you. If you add them by hand, open your domain's DNS records page and set every CNAME record to DNS only, the grey cloud, not proxied.
-   **Namecheap.** Open Domain List, choose Manage next to your domain, then add the records on the Advanced DNS tab.
-   **GoDaddy.** Open your domain's DNS page from your list of domains, then add each record.
-   **Amazon Route 53.** Open Hosted zones, choose your domain, then choose Create record for each one.

New records can take a few minutes to show up, and now and then longer. If a record shows **Not found yet**, wait and choose **Check now** again. If it shows **Different value** or **Added under the wrong name**, compare it with the page and fix it at your DNS host.

**Keep your MX records**Your MX records tell the internet where to deliver email sent to you. Do not delete or change them. Outbox Stack only sends email. The one MX record it asks for sits on the bounce subdomain, so it does not touch your inbox.

## Hand this to your developer

Send your developer this page and the sending only key from step 3. These are the exact steps.

1.  Store the key as a secret on your server, never in code. Set `MAIL_BASE_URL` to `https://outboxstack.app` and `MAIL_API_KEY` to the key.
2.  Send one email from the command line. Replace both addresses with a sender at your verified domain and a real test recipient.

```
curl "$MAIL_BASE_URL/v1/messages" \
  -H "Authorization: Bearer $MAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: reset-request-unique-id" \
  --data '{
    "from": "accounts@your-verified-domain.com",
    "fromName": "Your app",
    "to": "customer@example.com",
    "toName": "Ada Obi",
    "replyTo": "support@your-verified-domain.com",
    "subject": "Reset your password",
    "text": "Use the password-reset link generated by your app."
  }'
```

3.  Expect HTTP 202 with `"status":"queued"`. Queued means accepted, not yet delivered. [Read the full API guide](https://outboxstack.app/docs#api).
4.  Move the call into your backend with the API or an SDK. Guides cover [Node.js](https://outboxstack.app/docs#sdk), [PHP](https://outboxstack.app/docs#php), [Laravel](https://outboxstack.app/docs#laravel), [Python](https://outboxstack.app/docs#python) and [Go](https://outboxstack.app/docs#go). Any other language can use the API directly.
5.  Give each email an idempotency key built from the event that caused it, such as the reset request id. A retry with the same key never sends twice.
6.  Track delivery, bounces and complaints with webhooks. [Read Delivery & errors](https://outboxstack.app/docs#delivery).
7.  Use a test key in automated tests and staging. [Read about test mode](https://outboxstack.app/docs#test-mode) and the [limits](https://outboxstack.app/docs#limits).

**Keep the key on the server**Never put the API key in a website, browser code or a mobile app. Anyone can read code that runs on their own device, and a stolen key can send email as you. Your app's browser or phone code should ask your own server to send the email, and only the server talks to Outbox Stack. If a key leaks, revoke it on **API keys & SMTP** and create a new one.

## When something goes wrong

When the API refuses an email, it replies with an error. The `code` field names the problem and the `error` field explains it in words. Find the code below.

| Code or symptom | Cause | Fix |
| --- | --- | --- |
| 401 unauthorized | The key is missing, mistyped or revoked. The error says "invalid API key" or "sign in or send an API key". | Check the header reads `Authorization: Bearer` followed by the key. If in doubt, create a new key on **API keys & SMTP**. |
| 422 sending\_not\_configured | Nothing is set up to deliver app email. | Open **Sending providers**. Set up managed sending, or choose **Use for transactional email** on your provider's card. |
| 422 domain\_not\_verified | The From address uses a domain that is not added to this workspace, or is not verified yet. | Open **Domains**, add the domain or fix its records, and choose **Check now**. If the error says the domain is still being verified, wait a few minutes and try again. |
| 403 sender\_domain\_not\_allowed | The key is locked to a different domain than the From address. | Send from the domain the key allows, or create a key with **Send from** set to **Any of your domains**. |
| 422 sandbox\_recipient\_not\_allowed | The email comes from the sandbox address and goes to someone outside your workspace. | Verify your own domain and send from it. |
| 429 sandbox\_limit\_reached | The sandbox address sent 50 emails today. | Verify your own domain and send from it. |
| 429 rate\_limited | More than 1,200 requests a minute with one key. | Wait for the seconds in the `Retry-After` header, then retry with the same idempotency key. |
| 402 quota\_exceeded | This month's included emails and credits are used up. | Buy credits or choose a plan on **Billing**. |
| 403 account\_restricted | Sending on your account is suspended. | Read the reason in the error, then email support. |
| 400 missing\_content | The email has no subject with text or html, and no template. | Add a subject and a body. |
| 400 invalid\_address | The to or from field is not an email address. | Check both addresses. |
| Message shows Bounced | The receiving inbox refused it. The address may not exist or the inbox may be full. Outbox Stack adds hard bounces to your suppressed addresses. | Open the message on **Email activity** to read the reason. Ask the person for a correct address. |
| Message shows Suppressed | The address bounced before, marked your mail as spam, unsubscribed, or was added by hand. Outbox Stack does not send to it, to protect your reputation. | Open **Audience** and find it under **Suppressed addresses**. The reason column says why. Bounces, spam complaints and unsubscribes stay blocked. Only an address you added by hand can be removed. |

Every error also carries a `request_id`. Include it when you email support.

## Still stuck

If something looks broken for everyone, check the [status page](https://outboxstack.app/status). For anything else, email [support@outboxstack.app](mailto:support@outboxstack.app) with your workspace name and any `request_id` you saw.

Ready to start?[Open Sending providers](https://outboxstack.app/dashboard/providers)

---
Source: https://outboxstack.app/docs/send-app-email/
