Send email with Better Auth using Notify
Wire Better Auth email verification and password reset callbacks to Notify — sendVerificationEmail, sendResetPassword, optional magic link and Email OTP plugins.
Short answer: Better Auth calls your mail function when a user must verify email or reset a password — emailVerification.sendVerificationEmail and emailAndPassword.sendResetPassword (Better Auth email concepts). From those callbacks (and optional magic link / Email OTP plugins), POST to https://notify.cx/api/email/send with header x-api-key or use the notifycx SDK. Use a verified Notify domain for production from.
Notify is a transactional send API only — no SMTP. Better Auth does not ship email delivery; you bring your own provider (Better Auth — Bring your own email provider).
Related guides: Auth verification recipe · Password reset · Magic link & OTP
Prerequisites
- Notify API key (
NOTIFY_API_KEYon the server) - Verified domain for production
from(sandbox vs production) - Better Auth installed in your app (
better-auth)
npm install better-auth notifycx
Shared send helper
Keep NOTIFY_API_KEY server-side. Better Auth recommends not awaiting outbound mail inside auth callbacks to reduce timing side channels — fire the send without blocking the response, and on serverless use waitUntil (or equivalent) so the message still delivers (Better Auth email verification).
// lib/notify-mail.ts
async function deliverNotifyMail(opts: {
to: string;
subject: string;
html: string;
}) {
const res = await fetch('https://notify.cx/api/email/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.NOTIFY_API_KEY!
},
body: JSON.stringify({
to: opts.to,
from:
process.env.NOTIFY_FROM ??
'Auth <noreply@your-verified-domain.com>',
subject: opts.subject,
html: opts.html
})
});
if (!res.ok) throw new Error(await res.text());
}
export function queueNotifyMail(opts: {
to: string;
subject: string;
html: string;
}) {
const job = deliverNotifyMail(opts).catch((err) => {
console.error('Notify send failed', err);
});
// On Vercel / Cloudflare Workers, prefer waitUntil(job) when available.
void job;
}
Equivalent with notifycx:
import Notify from 'notifycx';
const notify = new Notify(process.env.NOTIFY_API_KEY!);
export async function deliverWithSdk(opts: {
to: string;
subject: string;
html: string;
}) {
await notify.send({
to: opts.to,
from: process.env.NOTIFY_FROM ?? 'noreply@your-verified-domain.com',
subject: opts.subject,
html: opts.html
});
}
See Sending emails and OpenAPI.
Better Auth server config
Callback names and shapes match Better Auth’s docs as of Nov 2026.
| Better Auth hook | Config path | Notify payload |
|---|---|---|
| Email verification link | emailVerification.sendVerificationEmail | to: user.email, link in html from url |
| Password reset link | emailAndPassword.sendResetPassword | to: user.email, link in html from url |
| Magic link sign-in | magicLink plugin → sendMagicLink | to: email, link from url |
| Email OTP | emailOTP plugin → sendVerificationOTP | to: email, OTP code in html |
Email verification + password reset (core)
// lib/auth.ts
import { betterAuth } from 'better-auth';
import { queueNotifyMail } from './notify-mail';
export const auth = betterAuth({
emailVerification: {
sendOnSignUp: true,
sendVerificationEmail: async ({ user, url }, _request) => {
queueNotifyMail({
to: user.email,
subject: 'Verify your email',
html: `
<p>Confirm your email to finish signing up.</p>
<p><a href="${url}">Verify email</a></p>
`
});
}
},
emailAndPassword: {
enabled: true,
sendResetPassword: async ({ user, url }, _request) => {
queueNotifyMail({
to: user.email,
subject: 'Reset your password',
html: `
<p>Click the link to choose a new password.</p>
<p><a href="${url}">Reset password</a></p>
`
});
}
}
});
Sources: sendVerificationEmail · sendResetPassword
Optional flags from the same page:
emailVerification.sendOnSignIn+emailAndPassword.requireEmailVerification— resend verification when an unverified user tries to sign inemailVerification.autoSignInAfterVerification— session after the user clicks the verify link
Magic link plugin (optional)
Only add this if you use Better Auth’s magic link flow (plugin docs).
import { magicLink } from 'better-auth/plugins';
plugins: [
magicLink({
sendMagicLink: async ({ email, url }, _ctx) => {
queueNotifyMail({
to: email,
subject: 'Sign in',
html: `<p><a href="${url}">Sign in with this link</a></p>`
});
}
})
];
Signature: sendMagicLink({ email, token, url, metadata }, ctx) (magic link configuration).
Email OTP plugin (optional)
For OTP sign-in / verify / forget-password (Email OTP plugin):
import { emailOTP } from 'better-auth/plugins';
plugins: [
emailOTP({
async sendVerificationOTP({ email, otp, type }) {
const subject =
type === 'forget-password'
? 'Your password reset code'
: type === 'email-verification'
? 'Your verification code'
: 'Your sign-in code';
queueNotifyMail({
to: email,
subject,
html: `<p>Your code is <strong>${otp}</strong>. It expires soon.</p>`
});
}
})
];
Signature: sendVerificationOTP({ email, otp, type }) where type is "sign-in", "email-verification", or "forget-password".
Test before production DNS
New Notify accounts are sandbox_only until you verify a domain. Rehearse the HTTP contract with POST /api/email/send/test (testing emails) while you wire Better Auth locally.
FAQ
Does Better Auth support Notify natively?
No single “Notify provider” switch — you implement the documented callbacks and call Notify from your server (Bring your own email provider).
Should I await notify.send inside Better Auth callbacks?
Better Auth advises against awaiting email in verification / reset callbacks to limit timing attacks; queue the send and use waitUntil on serverless (email verification note).
Can I use Notify SMTP with Better Auth?
Notify has no SMTP. Use fetch or notifycx to POST /api/email/send only.
What if sendVerificationEmail throws?
Better Auth logs the error and sign-up can still succeed (docs). Monitor Notify logs and handle failures in your queueNotifyMail helper.
Magic link vs email verification — which callback?
Email verification (sendVerificationEmail) confirms account email. Magic link (sendMagicLink) is passwordless sign-in via the magic link plugin — separate plugin and callback.
Next step
- Sign up and copy an API key from Credentials.
- Verify your sending domain (SPF/DKIM/DMARC).
- Paste the hooks above into your Better Auth config and trigger a sign-up / reset in dev.