> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autosend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to send emails from Managed Better Auth with SMTP

> Configure Managed Better Auth to send authentication emails through AutoSend SMTP.

![AutoSend x Neon](https://mintcdn.com/autosend-13920f5c/elz97IrcT4EqDdvp/images/smtp/autosendxneon.jpg?fit=max\&auto=format\&n=elz97IrcT4EqDdvp\&q=85\&s=0d0b815de3682b744c65e4cf04c60ea9)

[Managed Better Auth](https://neon.com/docs/auth/overview) is Neon's hosted version of [Better Auth](https://better-auth.com). It sends emails such as verification codes and password reset codes. By default, it sends them from a shared Neon address, which is rate-limited and meant for development. For production apps, you can configure it to send the same emails from your own domain through AutoSend SMTP.

## Prerequisites

> [card] [Verified Domain](https://autosend.com/settings/domains)
>
> Make sure you have a verified domain added in AutoSend to send emails from.

> [card] [SMTP Key](https://autosend.com/settings/smtp)
>
> Create a project-specific SMTP key from the SMTP tab in Project Settings.

## Configuration

### 1. Open Email Provider Settings

1. Go to the [Neon Console](https://console.neon.tech)
2. Select your project
3. Navigate to **Settings** → **Better Auth**
4. Under **Email provider**, click **Configure email provider**

### 2. Select Custom SMTP Provider

In the **Email provider** dropdown, select **Custom SMTP provider**.

### 3. Enter SMTP Credentials

Fill in the following settings:

| Field | Value |
| - | - |
| **Host** | `smtp.autosend.com` |
| **Port** | `587` (STARTTLS) or `465` (TLS) |
| **Username** | autosend |
| **Password** | Your AutoSend SMTP key |
| **Sender email** | `auth@yourdomain.com` (must match your verified domain) |
| **Sender name** | Your app name (e.g., "MyApp") |

> [!NOTE]
>
> The SMTP password is not your API key. Create a project-specific SMTP key from the SMTP tab in [Project Settings](https://autosend.com/settings/smtp).

### 4. Save Settings

Click **Save** to apply your SMTP configuration.

### 5. Test the Configuration

Under **Email provider**, click **Send test email**.

Check the recipient's inbox to confirm the email arrived from your sender address. The email also appears on the AutoSend [Email Activity](https://autosend.com/email-activities) page.

> [!NOTE]
>
> Each Neon branch has its own email provider settings, and a new branch copies the settings of its parent. Configure the provider on the branch your app uses.

## Alternative: Neon CLI

You can also set the SMTP provider with the [Neon CLI](https://neon.com/docs/cli/install). From a directory linked to your project, run:

```bash theme={null}
neon neon-auth config email-provider update \
  --type standard \
  --host smtp.autosend.com \
  --port 587 \
  --username autosend \
  --password "$AUTOSEND_SMTP_KEY" \
  --sender-email auth@yourdomain.com \
  --sender-name "MyApp"
```

Then send a test email:

```bash theme={null}
neon neon-auth config email-provider test --recipient-email you@example.com
```

## Email Templates

With SMTP, Managed Better Auth sends its own default email templates from your address. To design the emails in AutoSend instead, use Managed Better Auth [webhooks](https://neon.com/docs/auth/guides/webhooks): handle the `send.otp` and `send.magic_link` events and send each email with an AutoSend template.

> [card] [Send emails with Neon](https://docs.autosend.com/guides/neon.md)
>
> All the ways to use AutoSend with Neon, including webhooks and Neon Functions.

## Troubleshooting

> [accordion] Emails not being sent
>
> * Verify your SMTP credentials are correct
> * Check that your sender email is on a domain verified in AutoSend
> * Make sure you configured the provider on the branch your app uses

> [accordion] Emails go to a webhook instead of SMTP
>
> While a Managed Better Auth webhook subscribes to `send.otp` or `send.magic_link`, Neon sends those emails to the webhook instead of through SMTP. Remove those events from the webhook to send them through AutoSend SMTP.

> [accordion] Authentication failed
>
> * Ensure the username is `autosend` and the password is your SMTP key, not your API key
> * Verify your SMTP key is active in the [SMTP Settings](https://autosend.com/settings/smtp)

> [accordion] Emails going to spam
>
> * Ensure your domain has proper DNS records (SPF, DKIM, DMARC)
> * Use a sender name your users recognize
> * Check your domain reputation in AutoSend


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.