# How do I send email from my app with SMTP or the API?

> Connect your website or app to Phluit Email Sending: create a key, then use the SMTP settings or the HTTP API. Includes Laravel and cURL examples.

Source: https://docs.phluit.com/products/email-sending/email-sending-smtp-api/

Any app, framework or plugin that can send through SMTP works, and so does the HTTP API. [Verify your domain](/products/email-sending/email-sending-verify-domain/) first: you can only send from addresses on a verified domain.

## Create a key

1.  Open **Email → Email API** in the portal menu, then the **Keys** tab.
2.  Choose **SMTP key** or **API key**, give it a name, and click **Create key**.
3.  Copy the key right away. It isn't shown again; click **I saved it** when you're done.

Lost a key? **Delete** it and create a new one. Use a separate key for each app, so you can replace one without touching the others.

## SMTP settings

The **Overview** tab lists your exact settings under **How to send**:

-   **SMTP server:** the host shown there (for example `postal20.phluit.net`)
-   **Port:** 587 (or 25), with STARTTLS
-   **Username:** the username shown there
-   **Password:** your SMTP key

Example for a Laravel `.env` file:

```
MAIL_MAILER=smtp
MAIL_HOST=postal20.phluit.net
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_USERNAME=your-username-from-how-to-send
MAIL_PASSWORD=your-smtp-key
MAIL_FROM_ADDRESS=noreply@mail.example.com
```

In WordPress, use an SMTP plugin with the same values.

## HTTP API

Send a POST request to the API address shown under **How to send**, with your API key in the `X-Server-API-Key` header:

```
curl -X POST https://postal20.phluit.net/api/v1/send/message \
  -H "X-Server-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"from": "noreply@mail.example.com", "to": ["customer@example.org"], "subject": "Your receipt", "plain_body": "Thanks for your order."}'
```

You can also send `html_body`, `cc`, `bcc`, `reply_to`, `tag` and `attachments`. The reply contains an ID for each recipient, which you can look up on the **Activity** tab.

## If your app gets an error

-   **535 Mail server has been suspended** (SMTP) or **ServerSuspended** (API): sending is waiting for approval or is paused. See [Why was my email sending paused?](/products/email-sending/email-sending-paused/)
-   A From address that isn't on a verified domain is refused. Check the **Domains** tab.
