npm install nodemailer
yarn add nodemailer
pnpm add nodemailer
The Email provider sends "magic links" via email that the user can click on to sign in. You have likely seen them before if you have used software like Slack.
Adding support for signing in via email in addition to one or more OAuth services provides a way for users to sign in if they lose access to their OAuth account (e.g. if it is locked or deleted).
Configuration is similar to other providers, but the options are different:
import EmailProvider from "next-auth/providers/email"
// maxAge: 24 * 60 * 60, // How long email links are valid for (default 24h)
See the Email provider documentation for more information on how to configure email sign in.
The email provider requires a database, it cannot be used without one.
|id||Unique ID for the provider||Yes|
|name||Descriptive name for the provider||Yes|
|type||Type of provider, in this case ||Yes|
|server||Path or object pointing to the email server||Yes|
|sendVerificationRequest||Callback to execute when a verification request is sent||Yes|
|from||The email address from which emails are sent, default: "firstname.lastname@example.org"||No|
|maxAge||How long until the e-mail can be used to log the user in seconds. Defaults to 1 day||No|