Email Links Point to Wrong Domain
Symptom: Verification, password reset, or magic link emails containhttp://localhost:3000 or an old production URL.
Cause: BETTER_AUTH_URL and/or NEXT_PUBLIC_BASE_URL are misconfigured.
Update BETTER_AUTH_URL
In Vercel dashboard → Settings → Environment Variables:Apply to Production, Preview, and Development.
Emails Not Being Received
Check Nodemailer credentials
Check Nodemailer credentials
Verify in Vercel environment variables:
NODEMAILER_EMAIL— your Gmail addressNODEMAILER_PASSWORD— a Gmail app password (not your regular password)
- Enable 2FA on your Gmail account
- Go to App Passwords
- Generate a new password for “Mail”
Check spam folder
Check spam folder
Gmail SMTP emails may land in spam. Check the recipient’s spam/junk folder.
Gmail SMTP limits
Gmail SMTP limits
Gmail allows ~500 emails/day. If you’re hitting limits, consider switching to a dedicated service like SendGrid or AWS SES.
Check Vercel logs
Check Vercel logs
In Vercel dashboard → Deployments → click a deployment → View Logs. Look for:or error messages from Nodemailer.
Verification Link Doesn’t Work
Symptom: User clicks the verification link but still sees “Email not verified.” Common causes:-
Wrong HTTP method — The verification page must use
GET /api/auth/verify-email?token=..., notPOST. See Email Verification. - Token expired — Verification tokens expire after 24 hours. The user needs to request a new one.
- Token already used — Each token is one-time use. Clicking the link twice won’t work.
-
Wrong domain in URL — If
BETTER_AUTH_URLis incorrect, the verification endpoint won’t match. Check Vercel logs for the generated URL.
- Visit the debug endpoint:
https://your-domain.vercel.app/api/debug-env— should show correctbetterAuthUrl - Check the
usercollection in MongoDB:
Email Button Appears Black Instead of Yellow
Cause: Some email clients strip CSS gradients. Fix: The templates inlib/nodemailer/templates.ts use inline !important styles with a solid fallback:
Welcome Email Sent Before Verification
Symptom: Users receive the welcome email immediately after sign-up, before verifying. Fix: The welcome email should only be triggered by theonEmailVerification callback. Ensure:
signUpWithEmailsaves profile data touserprofilecollection without triggering InngestonEmailVerificationcallback inauth.tsfetches the profile and then sends the Inngestapp/user.createdevent- The temporary profile is cleaned up after the welcome email is triggered