Auth.js magic link email from your own domain
Runearc sends Auth.js (NextAuth v5) magic link emails from your own domain. Point the Nodemailer provider at smtp.runearc.com with an API key as the password, or write a custom email provider whose sendVerificationRequest calls Runearc's REST API with fetch. Both need a database adapter. We ran both end to end in a Next.js app.
npm install next-auth@beta nodemailer@8 @auth/pg-adapter pg
How it works
When someone asks for a sign in link, Auth.js makes a one time token, stores it through your database adapter, and calls the email provider's sendVerificationRequest with the address and the link. Runearc delivers that email from your domain. When the link is opened, Auth.js checks and deletes the token, creates the user if needed, and starts the session. Runearc only carries the email; the token, the user and the session stay in your app.
next-auth/providers/nodemailerPath 1: SMTP
Auth.js's Nodemailer provider withsmtp.runearc.com, userrunearcand your key. Auth.js's own email template, nothing else to write.POST /v1/emailsPath 2: the API
A custom email provider whosesendVerificationRequestcalls Runearc withfetch. No nodemailer, your own email body.adapterBoth need a database
Email sign in stores its tokens, so Auth.js requires an adapter. The snippets use PostgreSQL; any Auth.js adapter works.
Sources, read on November 25, 2026
- [1]Auth.js, Nodemailer provider: authjs.dev/getting-started/providers/nodemailer
- [2]Auth.js, HTTP email provider: authjs.dev/guides/configuring-http-email
- [3]Auth.js, PostgreSQL adapter and schema: authjs.dev/getting-started/adapters/pg
If something here is out of date or wrong, email hello@runearc.com and we will fix it.
Set up
Three things in Runearc and your app, then pick one of the two paths.
- 1
Verify your domain
Add it in Runearc and publish the records it lists, so sign in email goes out asnoreply@yourdomain. The records are explained in the domains docs. - 2
Create a Sending only key
On the API keys page. It can send and read the send log, nothing else. Inbox keys cannot send over SMTP. - 3
Install and set the env
Auth.js v5 is on thebetatag, and it does not install nodemailer for you. Add an adapter and its tables from the Auth.js adapter docs.
npm install next-auth@beta nodemailer@8 @auth/pg-adapter pgnext-auth 5.0.0-beta.32 accepts nodemailer 7 or 8; nodemailer 10 is outside its peer range.
AUTH_SECRET=... # npx auth secret
DATABASE_URL=postgres://... # the database your adapter uses
RUNEARC_API_KEY=mb_live_xxxxxxxxx # a Sending only key from the Runearc dashboardPath 1: the Nodemailer provider
Point Auth.js's Nodemailer provider at Runearc's SMTP server. Port 465 is TLS from the first byte; for port 587, set secure: false and requireTLS: true so the login never goes out before STARTTLS. The from address must be on a domain verified in the key's workspace. The provider sends Auth.js's default email, with the subject Sign in to yourapp.com and a sign in button.
import NextAuth from "next-auth";
import Nodemailer from "next-auth/providers/nodemailer";
import PostgresAdapter from "@auth/pg-adapter";
import { Pool } from "pg";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
export const { handlers, auth, signIn, signOut } = NextAuth({
// Email sign in stores a one time token, so Auth.js needs a database adapter.
adapter: PostgresAdapter(pool),
providers: [
Nodemailer({
server: {
host: "smtp.runearc.com",
port: 465,
secure: true, // TLS from the first byte; or port 587, secure: false, requireTLS: true
auth: { user: "runearc", pass: process.env.RUNEARC_API_KEY },
},
from: "Acme <noreply@acme.com>", // any address on your verified domain
}),
],
});import { handlers } from "@/auth";
export const { GET, POST } = handlers;Prefer a connection string? Auth.js also reads server: process.env.EMAIL_SERVER with EMAIL_SERVER=smtps://runearc:mb_live_...@smtp.runearc.com:465. Every SMTP setting is on the SMTP docs page.
Path 2: a custom provider with fetch
An Auth.js email provider is an object with type: "email" and a sendVerificationRequest function. This one posts the email to Runearc's Emails API, POST /v1/emails, so there is no SMTP connection and no nodemailer. If Runearc refuses the send, the error's code, message and fix go into the thrown error, so they show in your server log and the sign in request fails instead of pretending the email went out.
import NextAuth from "next-auth";
import type { EmailConfig } from "next-auth/providers/email";
import PostgresAdapter from "@auth/pg-adapter";
import { Pool } from "pg";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const esc = (s: string) => s.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
const runearc: EmailConfig = {
id: "runearc", // signIn("runearc", { email })
type: "email",
name: "Email",
from: "Acme <noreply@acme.com>",
maxAge: 60 * 60, // the link works for 1 hour (Auth.js default: 24 hours)
async sendVerificationRequest({ identifier, url, provider }) {
const { host } = new URL(url);
const res = await fetch("https://api.runearc.com/v1/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RUNEARC_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: provider.from,
to: identifier,
subject: `Sign in to ${host}`,
text: `Sign in to ${host}\n${url}\n\nIf you did not ask for this email, you can ignore it.`,
// data-runearc-track="false": click tracking leaves the one time link as it is.
html: `<p><a href="${esc(url)}" data-runearc-track="false">Sign in to ${esc(host)}</a></p>
<p>If you did not ask for this email, you can ignore it.</p>`,
tags: [{ name: "category", value: "magic-link" }],
}),
});
if (!res.ok) {
// Runearc errors are { error: { code, message, fix } }.
const { error } = await res.json();
throw new Error(`Runearc ${res.status} ${error.code}: ${error.message} ${error.fix ?? ""}`);
}
},
};
export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: PostgresAdapter(pool), // required for email sign in
providers: [runearc],
});import { handlers } from "@/auth";
export const { GET, POST } = handlers;Runearc tracks clicks on API sends by rewriting links into a redirect. A sign in link works once, so the snippet adds data-runearc-track="false" to it; without that attribute, the email would carry the tracked redirect instead of Auth.js's URL. The tracking options are in the Emails API docs. The tags entry lets you filter sign in emails in the sending log.
The sign in form
Call signIn with the provider id: nodemailer for path 1, or the id you gave the custom provider, runearc here. Auth.js then redirects to its "check your email" page.
import { signIn } from "@/auth";
export default function SignIn() {
return (
<form
action={async (formData) => {
"use server";
await signIn("nodemailer", formData); // "runearc" for the API provider
}}
>
<input type="email" name="email" placeholder="you@example.com" required />
<button type="submit">Email me a sign in link</button>
</form>
);
}A real run
Every snippet on this page passes tsc --noEmit in strict mode with next-auth 5.0.0-beta.32 (@auth/core 0.41.3), nodemailer 8.0.11, @auth/pg-adapter 1.11.3, pg 8.23.1, Next.js 16.4.6 and TypeScript 7.0.2, tested on November 25, 2026. We then ran the app against a local Runearc stack, with only the SMTP host and port and the API URL pointed at it, and signed in three times: through the Nodemailer provider on the TLS port, again on the STARTTLS port, and through the custom provider. Each time Auth.js redirected to its verify page, Runearc reported the email delivered, opening the link from the email signed the user in (/api/auth/session returned the address), and opening the same link again returned error=Verification. The recipients were Runearc's test addresses. The capture is at the top of this page.
What it does not do
- It does not store tokens or users. Auth.js and your adapter do. Runearc only sends the email, so you still need a database for email sign in.
- It does not change Auth.js's email. Path 1 sends Auth.js's default template. To change the subject or body, write your own
sendVerificationRequest, as in path 2. - It does not send from an unverified domain. Until your domain is verified, the workspace is in the sandbox and can only email your team and the test addresses.
- It does not stop link scanners. Some mail security tools open links before the user does, which uses up a one time link. That is true with any email provider; if your users report expired links, see the fixes below.
- No Runearc provider inside next-auth. Path 2 is a custom provider that lives in your code.
If the email does not arrive
- MissingAdapter: Email login requires an adapter
- Add a database adapter to
NextAuth(). Email sign in cannot work without one, even with JWT sessions. - 535 5.7.8 authentication failed
- The SMTP password is not a valid key, or
RUNEARC_API_KEYis not set where Auth.js runs. Use a Sending only key; inbox keys cannot send over SMTP. More on 535 5.7.8. - 550 5.7.1 not a domain of this workspace
- The
fromaddress is on a domain that is not verified in the key's workspace. Verify it, or changefrom. More on 550 5.7.1. - Runearc 403 sender_not_verified
- The same problem on the API path: the
fromdomain is not verified in the workspace. The thrown error includes Runearc's fix. - error=Verification when the user clicks
- The link was already used or expired. A scanner may have opened it first; with the API path, check that the link carries
data-runearc-track="false". RaisingmaxAgeonly helps with expiry. - Delivered, but in spam
- Send one sign in email to the email deliverability test to check SPF, DKIM and DMARC for your domain.
Sending your app's other email from Next.js, such as receipts? The Next.js guide uses the same key from route handlers. On Supabase instead of Auth.js? Supabase Auth custom SMTP needs no code at all. Every tool is in the integrations directory.
Questions
Which path should I pick, SMTP or the API?
SMTP if you want the least code: Auth.js's own Nodemailer provider and its default email, with four settings changed. The API if you would rather not install nodemailer, want your own email body, or run where outbound SMTP ports are blocked. Both reach the same Runearc sending log.
Does this work with NextAuth v4?
The settings do. In v4 the provider is EmailProvider from next-auth/providers/email, with the same server and from options, and sendVerificationRequest takes the same identifier and url. We ran the v5 code on this page, not v4.
Why does Auth.js need a database for email sign in?
The link carries a one time token that Auth.js stores and checks when the link is opened, so an adapter is required even with JWT sessions. Without one, Auth.js stops with MissingAdapter: Email login requires an adapter.
Can I use the built in Resend provider with Runearc?
No. Auth.js's Resend provider always calls api.resend.com and has no base URL option. Use the custom provider on this page, which sends the same kind of request to Runearc.
Are the sign in links click tracked?
Mail sent over SMTP is never tracked. Over the API, click tracking would turn the link into a redirect, so the snippet marks it with data-runearc-track="false" and the one time link reaches the user as Auth.js made it.
How long does the link work, and can it be used twice?
24 hours by default; set maxAge on the provider to change it. The token is deleted on first use: in our run, opening the same link again returned error=Verification.
What does it cost?
Runearc's free plan includes 3,000 emails a month and 3 custom domains, with no card. Pro is $9 a month for 50,000 emails.
Related integrations
- Next.jsSend from a route handler with the Resend SDK, the Runearc SDK or fetch.
- Supabase AuthCustom SMTP for sign up, magic link and password reset emails.
- Better AuthOne fetch helper for verification, reset, magic link, OTP and invitation emails.
- ClerkTurn off Delivered by Clerk, send each email.created webhook through Runearc's API.
Read next
Put Runearc to work
Get inboxes, sending, your own domains and MCP in one workspace. The free plan includes 3 inboxes, 3,000 emails a month and 3 custom domains, with no card.