The short answer: Better Auth does not send email itself. You give it functions such as sendVerificationEmail and sendResetPassword, and they call your email provider. Send with an email API, or over SMTP with Nodemailer and these settings:
Host: smtp.smtpfa.st
Port: 587 (or 2525), STARTTLS
Username: smtpfast
Password: an SMTPfast API key with the email:send scope
Either way, do not await the send inside the Better Auth callback, as the Better Auth docs advise, so the response time does not show whether an account exists.
We build SMTPfast. The Better Auth details below come from the Better Auth docs, checked on 22 November 2026; the links are at the end.
Step 1: verify your sending domain
- In SMTPfast, open Domains and add the domain you will send from, for example
auth.yourdomain.com. - Publish the records SMTPfast shows: three DKIM CNAME records, an SPF TXT record, a DMARC TXT record, and an MX and a TXT record for the
bounce.subdomain. On Cloudflare, Connect Cloudflare adds them for you. - Click Verify Now. The
fromaddress of every auth email must be on a verified domain.
See Domains for the record list.
Step 2: create an API key
Open API Keys and create a key with only the email:send scope. The same key works for the API and as the SMTP password.
# .env (server only)
SMTPFAST_API_KEY=sf_...
Step 3a: send with the email API
One module holds the send function. It labels the email transactional and sends the links untracked. The SDK retries a failed request with an idempotency key it makes for each call, so a retry does not send twice.
npm install @smtpfast/sdk
// lib/auth-email.ts
import { SMTPfast } from "@smtpfast/sdk";
const smtpfast = new SMTPfast(); // reads SMTPFAST_API_KEY
export async function sendAuthEmail(to: string, subject: string, url: string) {
await smtpfast.emails.send({
from: "Acme <[email protected]>",
to: [to],
subject,
html: `<p>${subject}:</p><p><a href="${url}">${url}</a></p>`,
text: `${subject}:\n${url}`,
category: "transactional",
track_clicks: false,
});
}
category: "transactional" keeps sign-in mail out of marketing opt-outs and leaves out the unsubscribe header. Without it, SMTPfast treats the email as marketing. track_clicks: false sends the link exactly as Better Auth built it.
Step 3b: or send over SMTP with Nodemailer
npm install nodemailer
// lib/auth-email.ts
import nodemailer from "nodemailer";
const transport = nodemailer.createTransport({
host: "smtp.smtpfa.st",
port: 587,
secure: false, // STARTTLS on 587; SMTPfast has no port 465
requireTLS: true,
auth: { user: "smtpfast", pass: process.env.SMTPFAST_API_KEY },
});
export async function sendAuthEmail(to: string, subject: string, url: string) {
await transport.sendMail({
from: "Acme <[email protected]>",
to,
subject,
html: `<p>${subject}:</p><p><a href="${url}">${url}</a></p>`,
text: `${subject}:\n${url}`,
headers: {
"X-SMTPfast-Category": "transactional",
"X-SMTPfast-Track-Clicks": "false",
},
});
}
Over SMTP, the two X-SMTPfast- headers do what the category and track_clicks fields do in the API. SMTPfast reads them and removes them before sending.
Step 4: wire it into Better Auth
// lib/auth.ts
import { betterAuth } from "better-auth";
import { magicLink } from "better-auth/plugins";
import { sendAuthEmail } from "./auth-email";
export const auth = betterAuth({
// database: ...
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
sendResetPassword: async ({ user, url }) => {
void sendAuthEmail(user.email, "Reset your password", url).catch(console.error);
},
},
emailVerification: {
sendOnSignUp: true,
sendVerificationEmail: async ({ user, url }) => {
void sendAuthEmail(user.email, "Verify your email address", url).catch(console.error);
},
},
plugins: [
magicLink({
sendMagicLink: async ({ email, url }) => {
void sendAuthEmail(email, "Your sign-in link", url).catch(console.error);
},
}),
],
});
Both versions of sendAuthEmail take the same arguments. The callbacks return at once and the email goes out in the background, as the Better Auth docs recommend. On a serverless platform the function can stop when the response is sent, so pass the promise to waitUntil (for example from @vercel/functions) or your platform's equivalent instead of void.
The Better Auth docs also note that an error thrown by sendVerificationEmail during sign-up does not stop the sign-up; it is logged. To block sign-ups when email fails, use a user.create.before database hook.
Step 5: test it
- Sign up with an address you can read, then request a password reset and a magic link.
- In SMTPfast, open Emails: each message shows its status and delivery attempts. To check the category, read the email with
GET /v1/emails/{id}(a key withemail:read):"category": "marketing"means the label did not arrive. - Open the original message in the inbox and check that SPF, DKIM and DMARC pass, or paste the headers into the email header analyzer.
Common errors
| What you see | Cause and fix |
|---|---|
535 Authentication failed (SMTP) or 401 (API) |
The SMTP username must be smtpfast and the password the full API key; the key needs email:send. |
550 (SMTP) or 403 (API): domain not verified |
The from address is not on a verified SMTPfast domain. |
| SMTP connection timeout | Port 465 is not open on SMTPfast; use 587 or 2525. Some hosts block outbound SMTP: use the API instead. |
451 (SMTP) or 429 (API) |
Your plan's hourly limit or a first-week stage. The SDK retries a 429; see Rate limits. |
| No email and no error | The send was not awaited and the function stopped first (serverless). Use waitUntil. Errors also only show in your logs, because of the .catch. |
| Users can request many emails | Better Auth's rate limiter is on in production by default (100 requests per 10 seconds, stricter on /sign-in/email) and off in development. Add rules for the routes that send email. |
| Mail lands in spam | Check that SPF, DKIM and DMARC pass for the from domain and that the email has a text part. |
Sources
Checked on 22 November 2026:
- Better Auth: Email (
sendVerificationEmail,sendResetPassword, do not await,waitUntil,user.create.before) - Better Auth: Rate limit
- Better Auth: Magic link plugin (
sendMagicLink) - SMTPfast: SMTP relay settings and the category header, SDKs
Other auth guides: Supabase Auth, Clerk, Auth.js / NextAuth and Firebase Authentication.
Frequently asked questions
Does Better Auth have built-in SMTP?
No. Better Auth calls functions you write, such as emailVerification.sendVerificationEmail, emailAndPassword.sendResetPassword and the magic link plugin's sendMagicLink. Inside them you send the email with any provider, over SMTP with Nodemailer or with an email API.
What are the SMTP settings for Better Auth with SMTPfast?
Host smtp.smtpfa.st, port 587 (or 2525) with STARTTLS, username smtpfast, and an SMTPfast API key with the email:send scope as the password. In Nodemailer that is host, port 587, secure false, requireTLS true and auth { user, pass }.
Should I await the email send in Better Auth?
No. Better Auth's docs advise against awaiting it, to prevent timing attacks: a request that waits for an email takes longer than one that does not, which can show whether an address has an account. On serverless platforms, pass the send to waitUntil or a similar function so it finishes after the response.
SMTP or API for Better Auth?
Either works. An API send is one HTTPS request and works where outbound SMTP ports are blocked or in Edge runtimes. SMTP with Nodemailer suits servers that already have a mail setup. With SMTPfast both reach the same sending pipeline; label auth email transactional with the category field (API) or the X-SMTPfast-Category header (SMTP).
Ready to get started?
Start sending transactional email today. Free to start, no credit card required.
Start freeRelated Posts
109 MCP Tools vs 2: What Compact Mode Saves (and Costs), Measured
SMTPfast's MCP server now has a compact mode at /api/mcp/compact: two tools, search_api and call_api, in place of 109. The tool list drops from 33,743 tokens to 634. In 100 measured runs on Claude Opus 5.5 and Claude Sonnet 5.5, every task passed in both modes, and compact mode sent 6.6 to 7.1 times fewer input tokens through the model. It was also slower (one more model turn per task), and with a warm prompt cache it cost about the same. It saves money when the tool list is not cached.
Best Email APIs for AI Agents in 2027 (7 Compared, 4 Fully Tested)
For an agent that needs its own inbox, four APIs passed every functional check we ran: SMTPfast, AgentMail, Resend Inboxes and Nylas Agent Accounts. All four sent, received in about 3 seconds, kept reply threads, handled attachments and worked through MCP in Claude Code. AgentMail is the fastest start (an inbox from one API call, no domain, no person); Nylas adds calendars and asks a person to confirm MCP sends; Resend fits if you already send with it; SMTPfast needs your own domain and a paid plan. Postmark received mail but could not send yet while its new-account review was pending. Tested on 22 November 2026.