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 Passwordless from "supertokens-node/recipe/passwordless";
import Session from "supertokens-node/recipe/session";
import { SMTPService } from "supertokens-node/recipe/passwordless/emaildelivery";
supertokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
Passwordless.init({
emailDelivery: {
service: new SMTPService({
smtpSettings: {
host: "...",
authUsername: "...", // this is optional. In case not given, from.email will be used
password: "...",
port: 465,
from: {
name: "...",
email: "...",
},
secure: true
},
})
},
}),
Session.init()
]
});
import (
"github.com/supertokens/supertokens-golang/ingredients/emaildelivery"
"github.com/supertokens/supertokens-golang/recipe/passwordless"
"github.com/supertokens/supertokens-golang/recipe/passwordless/plessmodels"
"github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
smtpUsername := "..."
supertokens.Init(supertokens.TypeInput{
RecipeList: []supertokens.Recipe{
passwordless.Init(plessmodels.TypeInput{
EmailDelivery: &emaildelivery.TypeInput{
Service: passwordless.MakeSMTPService(emaildelivery.SMTPServiceConfig{
Settings: 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,
},
}),
},
}),
},
})
}
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import passwordless
from supertokens_python.ingredients.emaildelivery.types import EmailDeliveryConfig, SMTPSettings, SMTPSettingsFrom
init(
app_info=InputAppInfo(
api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
passwordless.init(
email_delivery=EmailDeliveryConfig(
service=passwordless.SMTPService(
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
)
)
)
)
]
)
To learn about how to customise the default email templates or the subject, please see the next section.