Provide SMTP configuration
Using this method, you can:
- Send emails using your own domain
- Optionally customise the default email templates and subject.
- NodeJS
- GoLang
- Python
import supertokens from "supertokens-node";
import ThirdPartyPasswordless from "supertokens-node/recipe/thirdpartypasswordless";
import Session from "supertokens-node/recipe/session";
import { SMTPService } from "supertokens-node/recipe/thirdpartypasswordless/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: [
ThirdPartyPasswordless.init({
emailDelivery: {
service: new SMTPService({smtpSettings})
},
}),
// if email verificaiton is enabled..
EmailVerification.init({
emailDelivery: {
service: new EmailVerificationSMTPService({smtpSettings})
}
}),
Session.init()
]
});
import (
"github.com/supertokens/supertokens-golang/ingredients/emaildelivery"
"github.com/supertokens/supertokens-golang/recipe/emailverification"
"github.com/supertokens/supertokens-golang/recipe/emailverification/evmodels"
"github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless"
"github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless/tplmodels"
"github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
smtpUsername := "..."
smtpSettings := emaildelivery.SMTPSettings{
Host: "...",
From: emaildelivery.SMTPFrom{
Name: "...",
Email: "...",
},
Port: 456,
Username: &smtpUsername, // this is optional. In case not given, from.email will be used
Password: "...",
Secure: false,
}
supertokens.Init(supertokens.TypeInput{
RecipeList: []supertokens.Recipe{
thirdpartypasswordless.Init(tplmodels.TypeInput{
EmailDelivery: &emaildelivery.TypeInput{
Service: thirdpartypasswordless.MakeSMTPService(emaildelivery.SMTPServiceConfig{
Settings: smtpSettings,
}),
},
}),
// if email verification is enabled
emailverification.Init(evmodels.TypeInput{
EmailDelivery: &emaildelivery.TypeInput{
Service: emailverification.MakeSMTPService(emaildelivery.SMTPServiceConfig{
Settings: smtpSettings,
}),
},
}),
},
})
}
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import thirdpartypasswordless
from supertokens_python.ingredients.emaildelivery.types import EmailDeliveryConfig, SMTPSettingsFrom, SMTPSettings
from supertokens_python.recipe import emailverification
smtp_settings = SMTPSettings(
host="...",
port=465,
from_=SMTPSettingsFrom(
name="...",
email="..."
),
password="...",
secure=False,
username="..." # this is optional. In case not given, from_.email will be used
)
init(
app_info=InputAppInfo(
api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
thirdpartypasswordless.init(
email_delivery=EmailDeliveryConfig(
service=thirdpartypasswordless.SMTPService(
smtp_settings=smtp_settings
)
)
),
# If email verification is enabled
emailverification.init(
mode="OPTIONAL",
email_delivery=EmailDeliveryConfig(
service=emailverification.SMTPService(
smtp_settings=smtp_settings
)
)
)
]
)
To learn about how to customise the default email templates or the subject, please see the next section.