SMTP
NextAuth (SMTP)
Send NextAuth magic-link and verification emails through MailBlastr over SMTP.
NextAuth's Email provider sends sign-in (magic link) and verification emails over SMTP via Nodemailer. Point it at the MailBlastr SMTP relay and authenticate with your API key so auth emails are delivered and tracked in your dashboard.
Prerequisites
- A MailBlastr API key.
- A verified domain to send from.
1. Install
Install `next-auth` and `nodemailer` (the Email provider uses Nodemailer under the hood).
npm install next-auth nodemailer2. Configure SMTP credentials
Add your MailBlastr SMTP credentials to your application's .env file. The EMAIL_FROM address must be on a verified domain.
.env
EMAIL_SERVER_USER=mailblastr
EMAIL_SERVER_PASSWORD=mb_xxxxxxxxx
EMAIL_SERVER_HOST=smtp.mailblastr.com
EMAIL_SERVER_PORT=465
EMAIL_FROM=onboarding@yourdomain.com3. Configure the Email provider
In your [...nextauth].js file (typically under pages/api/auth), configure the Email provider with the SMTP settings from your environment.
[...nextauth].ts
import NextAuth from 'next-auth';
import EmailProvider from 'next-auth/providers/email';
export default NextAuth({
providers: [
EmailProvider({
server: {
host: process.env.EMAIL_SERVER_HOST,
port: process.env.EMAIL_SERVER_PORT,
auth: {
user: process.env.EMAIL_SERVER_USER,
pass: process.env.EMAIL_SERVER_PASSWORD,
},
},
from: process.env.EMAIL_FROM,
}),
// ... other providers as needed
],
// ... any other NextAuth.js configs
});Set
EMAIL_SERVER_PORT=587 to use STARTTLS instead of implicit TLS on port 465.