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

# Send NextAuth (Auth.js) emails through Nuntly

> Settings to send NextAuth and Auth.js magic link emails through Nuntly with the SDK or SMTP, and what differs between Auth.js v5 and NextAuth v4.

The NextAuth (Auth.js) email provider sends one email: the magic link that signs a user in. This page lists the settings to send it through Nuntly. For the step by step, the v4 setup and the migration to Better Auth, read the [NextAuth email provider guide](https://nuntly.com/blog/nextauth-email-provider).

## Before you start

* A database adapter in your Auth.js config. The email provider stores its verification token there, even with JWT sessions ([Auth.js email docs](https://authjs.dev/getting-started/authentication/email), read on November 14, 2026).
* An [API key](https://nuntly.com/docs/guides/api-keys.md) with send permission.
* A [verified sending domain](https://nuntly.com/docs/guides/sending-domains.md) for the `from` address. Until it is verified, an SDK send fails with `domain_not_verified`.

## Pick a route

| Route | Environment variables | What you control |
| - | - | - |
| SDK (custom HTTP email provider) | `NUNTLY_API_KEY` | Subject, HTML and text, error handling |
| SMTP (Nodemailer provider) | `EMAIL_SERVER`, `EMAIL_FROM` | Server and sender; Auth.js renders its default email |

## Versions

| | Auth.js v5 | NextAuth v4 |
| - | - | - |
| npm tag | `beta` | `latest` |
| SDK route | Provider object, `type: 'email'` | `EmailProvider` |
| SMTP route | `Nodemailer` provider | `EmailProvider` |
| Provider id | Your `id`, or `nodemailer` | `email` |
| Nodemailer | `nodemailer@8`, SMTP route only | `nodemailer@7`, both routes |
| Error page | `error=Configuration` | `error=EmailSignin` |

On v5, import `Nodemailer` from `next-auth/providers/nodemailer`; its peer range is `^7.0.7 || ^8.0.5`. On v4, pass your `sendVerificationRequest` (SDK route) or `server` and `from` (SMTP route) to `EmailProvider`; its peer range is `^7.0.7`. A failed send redirects to `/api/auth/error` with the error shown in the table.

The `beta` tag is `5.0.0-beta.32` and `latest` is `4.24.15`, read on npm on November 14, 2026 ([next-auth versions](https://www.npmjs.com/package/next-auth?activeTab=versions)). The guide's [troubleshooting section](https://nuntly.com/blog/nextauth-email-provider#when-the-sign-in-email-does-not-arrive) covers the server log and the error codes behind a failed send.

## SDK route on Auth.js v5

Install the [Nuntly TypeScript SDK](https://nuntly.com/docs/api-reference/typescript-sdk.md) with `npm install @nuntly/sdk`, set `NUNTLY_API_KEY`, and register a provider whose `sendVerificationRequest` sends the link:

```typescript theme={null}
// auth.ts
import NextAuth from 'next-auth';
import { PrismaAdapter } from '@auth/prisma-adapter';
import { Nuntly } from '@nuntly/sdk';
import { prisma } from '@/lib/prisma';

const nuntly = new Nuntly({ apiKey: process.env.NUNTLY_API_KEY });

export const { handlers, auth, signIn, signOut } = NextAuth({
  adapter: PrismaAdapter(prisma),
  providers: [
    {
      id: 'nuntly',
      type: 'email',
      name: 'Email',
      maxAge: 60 * 60 * 24,
      sendVerificationRequest: async ({ identifier, url }: { identifier: string; url: string }) => {
        const { host } = new URL(url);
        await nuntly.emails.send({
          from: 'Acme <auth@mail.example.com>',
          to: identifier,
          subject: `Sign in to ${host}`,
          text: `Sign in to ${host}:\n${url}\n\nIf you did not request this email, ignore it.`,
        });
      },
    },
  ],
});
```

`identifier` is the user's email address and `url` the sign-in link. `maxAge` sets how long the link stays valid, in seconds; the default is 24 hours ([Auth.js email docs](https://authjs.dev/getting-started/authentication/email), read on November 14, 2026). Start the sign-in with `signIn('nuntly', formData)`.

## SMTP route

The username is `nuntly` and the password is your API key:

```bash theme={null}
EMAIL_SERVER=smtp://nuntly:ntly_your_api_key@smtp.nuntly.com:587
EMAIL_FROM="Acme <auth@mail.example.com>"
```

Pass both to the provider as `server` and `from`. On port 587, Nodemailer upgrades the connection with STARTTLS before it authenticates. The [SMTP guide](https://nuntly.com/docs/guides/send-emails-with-smtp.md) has the full relay settings.

## Learn more

> [card] [NextAuth email provider guide](https://nuntly.com/blog/nextauth-email-provider)
>
> Both routes on v5 and v4, troubleshooting, and the migration to Better Auth

> [card] [Better Auth](https://nuntly.com/docs/guides/auth-better-auth.md)
>
> The callbacks that replace the email provider after a migration


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