Skip to content

Commit

Permalink
Merge pull request #396 from supertokens/smtp-fix
Browse files Browse the repository at this point in the history
fix: smtp tls config
  • Loading branch information
rishabhpoddar authored Feb 8, 2024
2 parents 068dd41 + 3a16488 commit 0883a0f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.17.4] - 2024-02-08

- Adds `TLSConfig` to SMTP settings.
- `TLSConfig` is always passed to gomail so that it can be used when gomail uses `STARTTLS` to upgrade the connection to TLS. - https://github.com/supertokens/supertokens-golang/issues/392
- Not setting `InsecureSkipVerify` to `true` in the SMTP settings because it is not recommended to use it in production.

## [0.17.3] - 2023-12-12

- CI/CD changes
Expand Down
6 changes: 5 additions & 1 deletion ingredients/emaildelivery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ func SendSMTPEmail(settings SMTPSettings, content EmailContent) error {
}

d := gomail.NewDialer(settings.Host, settings.Port, username, settings.Password)
if settings.TLSConfig != nil {
d.TLSConfig = settings.TLSConfig
} else {
d.TLSConfig = &tls.Config{ServerName: settings.Host}
}

if settings.Secure {
d.TLSConfig = &tls.Config{InsecureSkipVerify: true, ServerName: settings.Host}
d.SSL = true
}
return d.DialAndSend(m)
Expand Down
15 changes: 9 additions & 6 deletions ingredients/emaildelivery/smtpmodels.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
package emaildelivery

import (
"crypto/tls"

"github.com/supertokens/supertokens-golang/supertokens"
)

type SMTPSettings struct {
Host string
From SMTPFrom
Port int
Username *string
Password string
Secure bool
Host string
From SMTPFrom
Port int
Username *string
Password string
Secure bool
TLSConfig *tls.Config
}

type SMTPFrom struct {
Expand Down
2 changes: 1 addition & 1 deletion supertokens/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
)

// VERSION current version of the lib
const VERSION = "0.17.3"
const VERSION = "0.17.4"

var (
cdiSupported = []string{"3.0"}
Expand Down

0 comments on commit 0883a0f

Please sign in to comment.