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 ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword";import Session from "supertokens-node/recipe/session";import { SMTPService } from "supertokens-node/recipe/thirdpartyemailpassword/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: [ ThirdPartyEmailPassword.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/thirdpartyemailpassword" "github.com/supertokens/supertokens-golang/recipe/thirdpartyemailpassword/tpepmodels" "github.com/supertokens/supertokens-golang/recipe/emailverification" "github.com/supertokens/supertokens-golang/recipe/emailverification/evmodels" "github.com/supertokens/supertokens-golang/supertokens")
func main() { smtpSettings := emaildelivery.SMTPSettings{ Host: "...", From: emaildelivery.SMTPFrom{ Name: "...", Email: "...", }, Port: 456, Password: "...", Secure: false, }
supertokens.Init(supertokens.TypeInput{ RecipeList: []supertokens.Recipe{ thirdpartyemailpassword.Init(&tpepmodels.TypeInput{ EmailDelivery: &emaildelivery.TypeInput{ Service: thirdpartyemailpassword.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, InputAppInfofrom supertokens_python.recipe import thirdpartyemailpasswordfrom supertokens_python.ingredients.emaildelivery.types import EmailDeliveryConfig, SMTPSettingsFrom, SMTPSettingsfrom 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=[ thirdpartyemailpassword.init( email_delivery=EmailDeliveryConfig( service=thirdpartyemailpassword.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.