Interface: EmailConfig
providers/email.EmailConfig
The Email Provider needs to be configured with an e-mail client.
By default, it uses nodemailer
, which you have to install if this
provider is present.
You can use a other services as well, like:
See
Custom email service with Auth.js
Hierarchyβ
β³
EmailConfig
Propertiesβ
idβ
β’ id: string
Uniquely identifies the provider in AuthConfig.providers It's also part of the URL
Inherited fromβ
nameβ
β’ name: string
The provider name used on the default sign-in page's sign-in button. For example if it's "Google", the corresponding button will say: "Sign in with Google"
Inherited fromβ
sendVerificationRequestβ
β’ sendVerificationRequest: (params
: SendVerificationRequestParams
) => Awaitable
<void
>
Type declarationβ
βΈ (params
): Awaitable
<void
>
Parametersβ
Name | Type |
---|---|
params | SendVerificationRequestParams |
Returnsβ
Awaitable
<void
>
fromβ
β’ Optional
from: string
Default
"Auth.js <no-reply@authjs.dev>"
generateVerificationTokenβ
β’ Optional
generateVerificationToken: () => Awaitable
<string
>
Type declarationβ
βΈ (): Awaitable
<string
>
By default, we are generating a random verification token. You can make it predictable or modify it as you like with this method.
Example
Providers.Email({
async generateVerificationToken() {
return "ABC123"
}
})
Returnsβ
Awaitable
<string
>
maxAgeβ
β’ Optional
maxAge: number
How long until the e-mail can be used to log the user in, in seconds. Defaults to 1 day
Default
86400
normalizeIdentifierβ
β’ Optional
normalizeIdentifier: (identifier
: string
) => string
Type declarationβ
βΈ (identifier
): string
Normalizes the user input before sending the verification request.
β οΈ Always make sure this method returns a single email address.
Note
Technically, the part of the email address local mailbox element
(everything before the @
symbol) should be treated as 'case sensitive'
according to RFC 2821, but in practice this causes more problems than
it solves, e.g.: when looking up users by e-mail from databases.
By default, we treat email addresses as all lower case,
but you can override this function to change this behavior.
Documentation | RFC 2821 | Email syntax
Parametersβ
Name | Type |
---|---|
identifier | string |
Returnsβ
string
secretβ
β’ Optional
secret: string
If defined, it is used to hash the verification token when saving to the database .