Skip to main content

Provide SMTP configuration

Using this method, you can:

  • Send emails using your own domain
  • Optionally customise the default email templates and subject.
import supertokens from "supertokens-node";
import EmailPassword from "supertokens-node/recipe/emailpassword";
import Session from "supertokens-node/recipe/session";
import { SMTPService } from "supertokens-node/recipe/emailpassword/emaildelivery";
import EmailVerification from "supertokens-node/recipe/emailverification"
import { SMTPService as EmailVerificationSMTPService } from "supertokens-node/recipe/emailverification/emaildelivery";

let smtpSettings = {
host: "...",
authUsername: "...", // this is optional. In case not given, from.email will be used
password: "...",
port: 465,
from: {
name: "...",
email: "...",
},
secure: true
}

supertokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
EmailPassword.init({

emailDelivery: {
service: new SMTPService({smtpSettings})
},
}),

// if email verification is enabled..
EmailVerification.init({
emailDelivery: {
service: new EmailVerificationSMTPService({smtpSettings})
}
}),
Session.init()
]
});

To learn about how to customise the default email templates or the subject, please see the next section.

Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI