# n8n

Send email from n8n workflows through Sendora's SMTP, with the Send Email node.

Send the email that your n8n workflows write through Sendora's SMTP, with n8n's **Send Email** node. The node signs in with an SMTP credential that you create once and choose in each node.

## 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 your workflows' email comes from.
- An n8n user who can create credentials and workflows.

## Set up n8n

1. Add the domain that your workflows' email 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. In n8n, open **Overview** and its **Credentials** tab, and click **Create credential**. Choose **SMTP**, click **Continue**, and enter Sendora's values:

| Field    | Value             |
| -------- | ----------------- |
| User     | The server key    |
| Password | The server key    |
| Host     | `smtp.sendora.se` |
| Port     | `465`             |
| SSL/TLS  | On                |

Port 465 encrypts the connection from the first byte. Port 587 works too, with **SSL/TLS** off and **Disable STARTTLS** off. n8n then starts TLS only if the server offers it. [Its Send Email node](https://github.com/n8n-io/n8n/blob/n8n%402.49.8/packages/nodes-base/nodes/EmailSend/v2/utils.ts#L21-L29) never passes `requireTLS` to [Nodemailer](https://nodemailer.com/smtp#tls-options) in 2.49.8. If someone between n8n and Sendora removed that offer, n8n would send the key unencrypted, so use 465 where you can. If n8n runs on a host that blocks ports 465 and 587, such as a DigitalOcean Droplet, use port 2525 as you would 587.

4. Click **Save**. n8n signs in to test the credential, and shows **Connection tested successfully**.
5. Add a **Send Email** node to a workflow, and choose the credential in its **Credential** field.
6. Put an address on your verified domain in **From Email**, such as `Example <no-reply@example.se>`, and fill in **To Email**, **Subject** and the text. By default, the node ends each email with a line about n8n. To leave it out, choose **Add option**, then **Append n8n Attribution**, and switch it off.
7. Click **Execute step**.
8. Find the message on the server's **Messages** tab under [Servers](https://app.sendora.se/servers).
9. Once your account is approved, create a key on your live server's **API keys** tab, such as the default server that signup made. Open the credential, put the key in **User** and **Password** in place of the test key, and click **Save**.

The node's output holds Sendora's reply in `response`. The message's id, which the log and the webhooks use, follows `queued as`, or `accepted as` on a test server. Sendora writes its own `Message-ID`, so the output's `messageId` is not that id.

## If a message is refused

If Sendora refuses the key when you save the credential, n8n shows **Couldn’t connect with these settings**, and **More details** gives Sendora's reply. When Sendora refuses a message, the Send Email node fails with an error that holds the reply, such as `Message failed: 550 5.7.1`.

`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 n8n sends a message, click **Check now**.
