Skip to main content

Change email content

To change the content of the default email templates, you can override the getContent function in the emailDelivery object. It allows you to return an object that has the following properties:

  • body: This is the email's body. This can be HTML or just text as well.
  • isHtml: If the body is HTML, then this should be true.
  • subject: This is the subject of the email to send.
  • toEmail: The email will be sent to this email.

Other information like which email ID to send from is specified in the smtpSettings object.

import supertokens from "supertokens-node";
import Passwordless from "supertokens-node/recipe/passwordless";
import Session from "supertokens-node/recipe/session";
import { SMTPService } from "supertokens-node/recipe/passwordless/emaildelivery";

appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
recipeList: [
emailDelivery: {
service: new SMTPService({
smtpSettings: { /*...*/ },
override: (originalImplementation) => {
return {
getContent: async function ({
codeLifetime, // amount of time the code is alive for (in MS)
urlWithLinkCode, // magic link
userInputCode, // OTP
}) {
if (isFirstFactor) {
// this is for first factor login
return {
body: "EMAIL BODY",
isHtml: true,
subject: "Login to your account",
toEmail: email
} else {
// this is for MFA login (only applicable if you are using MFA).
// In this case, the urlWithLinkCode will always be undefined since
// we only support OTP based MFA and not link based MFA
return {
body: "EMAIL BODY",
isHtml: true,
subject: "Login via MFA",
toEmail: email

// You can even call the original implementation and
// modify its content:

let originalContent = await originalImplementation.getContent(input)
originalContent.subject = "My custom subject";
return originalContent;
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI