Send the mail that a self-hosted Directus writes, such as password resets, invitations, mentions and the emails that flows send, through Sendora’s SMTP. This guide is for a Directus that runs from its Docker image with Docker Compose, which passes Directus its settings as environment variables.
A Sendora account. A test server works from the moment the account exists. A live server sends once your account is approved. The account starts on Free, within the limits that Account › Usage in the dashboard shows.
Access to the DNS of the domain that Directus’s mail comes from.
Access to the folder that holds Directus’s docker-compose.yml, and an administrator’s account in Directus.
Add the domain that Directus’s mail comes from under Domains, and add the two DNS records it shows, as Domains explains.
Create a test server under Servers › New server, with Testserver ticked, and create a key on its API keys tab. The key starts with sk_test_. A test server takes mail as a live server does and delivers none of it.
Add the key to the .env file beside docker-compose.yml:
SENDORA_API_TOKEN=sk_test_…
In docker-compose.yml, add these lines to the environment of the Directus service, and keep the lines it has already:
Docker Compose fills in ${SENDORA_API_TOKEN} from .env, so the key stays out of docker-compose.yml. Put an address on your verified domain in EMAIL_FROM. Directus sends its mail from it, with your project’s name as the sender’s name.
Port 465 encrypts the connection from the first byte. Port 587 works too, with EMAIL_SMTP_SECURE set to "false". Directus then starts TLS only if the server offers it, since its mailer never passes requireTLS to Nodemailer in 12.7.0. If someone between Directus and Sendora removed that offer, Directus would send the key unencrypted, and no setting prevents it. So use 465 where you can.
If Directus runs on a host that blocks ports 465 and 587, such as a DigitalOcean Droplet, use port 2525 as you would 587.
In the same folder, run docker compose up -d, which recreates the Directus container with the new settings.
Sign out of the Data Studio, or open it in a private window. On its sign-in page, click Forgot Password, enter your address, and click Reset.
Find the message on the server’s Messages tab under Servers.
Once your account is approved, create a key on your live server’s API keys tab, such as the default server that signup made. Put it in SENDORA_API_TOKEN in place of the test key, and run docker compose up -d again.
If your host runs Directus without a Compose file and takes its environment variables in its own settings, set the same variables there. Put the key itself in EMAIL_SMTP_USER and EMAIL_SMTP_PASSWORD.
Directus sends its mail in the background, so the Data Studio shows no error when Sendora refuses a message. Directus logs an error such as Could not send password reset mail instead, with Sendora’s reply, such as Invalid login: 535 5.7.8 or Message failed: 550 5.7.1. Run docker compose logs directus to read the log.
Directus also signs in to Sendora to check its settings. Signed in to the Data Studio as an administrator, open /server/health at your Directus’s address. Its email:connection check shows Sendora’s reply when Sendora refuses the key.
535 5.7.8 means the key is wrong or revoked. 550 5.7.1 means the From domain is not verified, or that a live server’s account is not yet approved. 451 4.7.0 means that a limit is reached, such as Free’s daily limit. 550 5.1.1 means the recipient’s address is on the suppression list, for example after a hard bounce. SMTP replies lists every reply.
On the server’s API keys tab under Servers, Test the setup shows each valid key’s latest sign-in and accepted message over SMTP. It also shows the key’s latest refusals, each with what to do. After Directus sends a message, click Check now.
# Directus
Send a self-hosted Directus's password resets, invitations and flow emails through Sendora's SMTP.
Send the mail that a self-hosted Directus writes, such as password resets, invitations, mentions and the emails that flows send, through Sendora's SMTP. This guide is for a Directus that runs from its Docker image with Docker Compose, which passes Directus its settings as environment variables.
## Before you start
- A Sendora account. A test server works from the moment the account exists. A live server sends once your account is approved. The account starts on Free, within the [limits](https://sendora.se/docs/limits#the-free-tier) that [Account › Usage](https://app.sendora.se/account/usage) in the dashboard shows.
- Access to the DNS of the domain that Directus's mail comes from.
- Access to the folder that holds Directus's `docker-compose.yml`, and an administrator's account in Directus.
## Set up Directus
1. Add the domain that Directus's mail comes from under [Domains](https://app.sendora.se/domains), and add the two DNS records it shows, as [Domains](https://sendora.se/docs/domains) explains.
2. Create a test server under [Servers › New server](https://app.sendora.se/servers/new), with **Testserver** ticked, and create a key on its **API keys** tab. The key starts with `sk_test_`. A [test server](https://sendora.se/docs/test-servers) takes mail as a live server does and delivers none of it.
3. Add the key to the `.env` file beside `docker-compose.yml`:
```bash
SENDORA_API_TOKEN=sk_test_…
```
4. In `docker-compose.yml`, add these lines to the `environment` of the Directus service, and keep the lines it has already:
```yaml
services:
directus:
environment:
EMAIL_TRANSPORT: 'smtp'
EMAIL_SMTP_HOST: 'smtp.sendora.se'
EMAIL_SMTP_PORT: '465'
EMAIL_SMTP_SECURE: 'true'
EMAIL_SMTP_USER: '${SENDORA_API_TOKEN}'
EMAIL_SMTP_PASSWORD: '${SENDORA_API_TOKEN}'
EMAIL_FROM: 'no-reply@example.se'
```
Docker Compose fills in `${SENDORA_API_TOKEN}` from `.env`, so the key stays out of `docker-compose.yml`. Put an address on your verified domain in `EMAIL_FROM`. Directus sends its mail from it, with your project's name as the sender's name.
Port 465 encrypts the connection from the first byte. Port 587 works too, with `EMAIL_SMTP_SECURE` set to `"false"`. Directus then starts TLS only if the server offers it, since [its mailer](https://github.com/directus/directus/blob/v12.7.0/api/src/mailer.ts#L48-L57) never passes `requireTLS` to [Nodemailer](https://nodemailer.com/smtp#tls-options) in 12.7.0. If someone between Directus and Sendora removed that offer, Directus would send the key unencrypted, and no setting prevents it. So use 465 where you can.
If Directus runs on a host that blocks ports 465 and 587, such as a DigitalOcean Droplet, use port 2525 as you would 587.
5. In the same folder, run `docker compose up -d`, which recreates the Directus container with the new settings.
6. Sign out of the Data Studio, or open it in a private window. On its sign-in page, click **Forgot Password**, enter your address, and click **Reset**.
7. Find the message on the server's **Messages** tab under [Servers](https://app.sendora.se/servers).
8. Once your account is approved, create a key on your live server's **API keys** tab, such as the default server that signup made. Put it in `SENDORA_API_TOKEN` in place of the test key, and run `docker compose up -d` again.
If your host runs Directus without a Compose file and takes its environment variables in its own settings, set the same variables there. Put the key itself in `EMAIL_SMTP_USER` and `EMAIL_SMTP_PASSWORD`.
## If a message is refused
Directus sends its mail in the background, so the Data Studio shows no error when Sendora refuses a message. Directus logs an error such as `Could not send password reset mail` instead, with Sendora's reply, such as `Invalid login: 535 5.7.8` or `Message failed: 550 5.7.1`. Run `docker compose logs directus` to read the log.
Directus also signs in to Sendora to check its settings. Signed in to the Data Studio as an administrator, open `/server/health` at your Directus's address. Its `email:connection` check shows Sendora's reply when Sendora refuses the key.
`535 5.7.8` means the key is wrong or revoked. `550 5.7.1` means the From domain is not verified, or that a live server's account is not yet approved. `451 4.7.0` means that a limit is reached, such as Free's [daily limit](https://sendora.se/docs/limits#the-free-tier). `550 5.1.1` means the recipient's address is on the [suppression list](https://sendora.se/docs/suppressions), for example after a hard bounce. [SMTP replies](https://sendora.se/docs/smtp#smtp-replies) lists every reply.
## Test the setup
On the server's **API keys** tab under [Servers](https://app.sendora.se/servers), **Test the setup** shows each valid key's latest sign-in and accepted message over SMTP. It also shows the key's latest refusals, each with what to do. After Directus sends a message, click **Check now**.