# Email delivery

Backends in your projects send email through a mail account that you store for the organization, either as a Mailtrap, Resend, or SendGrid connection or as a generic SMTP account.

> Source: https://www.mainpath.ai/en/docs/email-delivery/

Backends send mail through a **mail account** that you store for the organization under **Connections**; the connection types appear together in projects in the **Mail account** picker.

## Mailtrap, Resend, SendGrid, or generic SMTP

**Mailtrap**, **Resend**, and **SendGrid** are the recommended options when the provider offers a single API token for sending and domain management. You store only the token and, optionally, a sender name and sender address; MainPath sends through SMTP and shows status and your sending domains with DNS checks in the detail view, where you also create new sending domains.

**Email (SMTP)** is a generic SMTP account with **host**, **port**, **username**, **password** or **API key**, **sender address**, and **sender name** for any other provider.

[SMTP, IMAP and co.]({{< relref "email-protocols-smtp-imap" >}}) explains how SMTP differs from IMAP and POP3.

## Flow with Mailtrap, Resend, or SendGrid

1. Create an API token at the provider, as described under [SMTP with Mailtrap]({{< relref "smtp-mailtrap-setup" >}}), [SMTP with Resend]({{< relref "smtp-resend-setup" >}}), or [SMTP with SendGrid]({{< relref "smtp-sendgrid-setup" >}}).
2. Under **Connections**, use the matching tile to create a connection with that token.
3. Verify your sending domain with the DNS records from the connection's detail view.
4. Select the connection in the project as the **Mail account**; the generated backend reads the credentials from its configuration.

## Flow with generic SMTP

1. Create an account with your email provider and note the host, port, username, and password.
2. Under **Connections**, use the **Email (SMTP)** tile to create an entry with those values plus the sender address and sender name.
3. Select the connection in the project as the **Mail account**.

Locally, `mp run-local` also starts Mailhog for backends, which shows outgoing mail in the browser.

## Keep credentials narrow

Use API keys, tokens, or app passwords from the provider instead of your personal login, and restrict the account's permissions to sending.

