How to send Emails with Gmail and Nodemailer for Auth for NextAuth.js

How to send Emails with Gmail and Nodemailer for Auth for NextAuth.js


Here is my example authOptions.

export const authOptions: NextAuthOptions = {
	adapter: DrizzleAdapter(db) as Adapter,
	callbacks: {
		session: ({ session, user }) => {
			session.user.id = user.id;
			return session;
		},
		signIn: async (params) => {
		
		},
	},
	providers: [
		Email({
			server: {
				host: "smtp.gmail.com",
				port: 465,
				secure: true,
				auth: {
					user: env.GMAIL_USER,
					pass: env.GMAIL_PASS,
				},
			},
			from: "Fastzayn",
		}),
		GoogleProvider({
			clientId: env.GOOGLE_CLIENT_ID,
			clientSecret: env.GOOGLE_CLIENT_SECRET,
		}),
		AppleProvider({
			clientId: env.APPLE_CLIENT_ID,
			clientSecret: env.APPLE_CLIENT_SECRET,
		}),
	],
};


Here is my example authOptions.

export const authOptions: NextAuthOptions = {
	adapter: DrizzleAdapter(db) as Adapter,
	callbacks: {
		session: ({ session, user }) => {
			session.user.id = user.id;
			return session;
		},
		signIn: async (params) => {
		
		},
	},
	providers: [
		Email({
			server: {
				host: "smtp.gmail.com",
				port: 465,
				secure: true,
				auth: {
					user: env.GMAIL_USER,
					pass: env.GMAIL_PASS,
				},
			},
			from: "Fastzayn",
		}),
		GoogleProvider({
			clientId: env.GOOGLE_CLIENT_ID,
			clientSecret: env.GOOGLE_CLIENT_SECRET,
		}),
		AppleProvider({
			clientId: env.APPLE_CLIENT_ID,
			clientSecret: env.APPLE_CLIENT_SECRET,
		}),
	],
};

© 2023 Bedirhan

Have a great day

© 2023 Bedirhan

Have a great day