Skip to content

Commit 0883a0f

Browse files
Merge pull request #396 from supertokens/smtp-fix
fix: smtp tls config
2 parents 068dd41 + 3a16488 commit 0883a0f

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
## [0.17.4] - 2024-02-08
11+
12+
- Adds `TLSConfig` to SMTP settings.
13+
- `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
14+
- Not setting `InsecureSkipVerify` to `true` in the SMTP settings because it is not recommended to use it in production.
15+
1016
## [0.17.3] - 2023-12-12
1117

1218
- CI/CD changes

ingredients/emaildelivery/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ func SendSMTPEmail(settings SMTPSettings, content EmailContent) error {
5858
}
5959

6060
d := gomail.NewDialer(settings.Host, settings.Port, username, settings.Password)
61+
if settings.TLSConfig != nil {
62+
d.TLSConfig = settings.TLSConfig
63+
} else {
64+
d.TLSConfig = &tls.Config{ServerName: settings.Host}
65+
}
6166

6267
if settings.Secure {
63-
d.TLSConfig = &tls.Config{InsecureSkipVerify: true, ServerName: settings.Host}
6468
d.SSL = true
6569
}
6670
return d.DialAndSend(m)

ingredients/emaildelivery/smtpmodels.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@
1717
package emaildelivery
1818

1919
import (
20+
"crypto/tls"
21+
2022
"github.com/supertokens/supertokens-golang/supertokens"
2123
)
2224

2325
type SMTPSettings struct {
24-
Host string
25-
From SMTPFrom
26-
Port int
27-
Username *string
28-
Password string
29-
Secure bool
26+
Host string
27+
From SMTPFrom
28+
Port int
29+
Username *string
30+
Password string
31+
Secure bool
32+
TLSConfig *tls.Config
3033
}
3134

3235
type SMTPFrom struct {

supertokens/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
)
2222

2323
// VERSION current version of the lib
24-
const VERSION = "0.17.3"
24+
const VERSION = "0.17.4"
2525

2626
var (
2727
cdiSupported = []string{"3.0"}

0 commit comments

Comments
 (0)