// https://craftingemails.com/blog/nextauth-signin-custom-email import { Theme } from "next-auth" import { createTransport } from "nodemailer" export async function CustomsendVerificationRequest(params) { const { identifier, url, provider, theme } = params const { host } = new URL(url) // NOTE: You are not required to use `nodemailer`, use whatever you want. const transport = createTransport(provider.server) const result = await transport.sendMail({ to: identifier, from: provider.from, subject: `Sign in to ${host}`, text: text({ url, host }), html: html({ url, host, theme }), }) const failed = result.rejected.concat(result.pending).filter(Boolean) if (failed.length) { throw new Error(`Email(s) (${failed.join(", ")}) could not be sent`) } } function html(params: { url: string; host: string; theme: Theme }) { const { url, host, theme } = params const escapedHost = host.replace(/\./g, "​.") return ` Connection à Thé Tip Top
Connexion à Thé Tip Top ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏
` } // Email Text body (fallback for email clients that don't render HTML) function text({ url, host }: { url: string; host: string }) { return `Connectez vous à ${host}\n${url}\n\n` }