Skip to content

Commit

Permalink
fix: smtp tls config
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Feb 8, 2024
1 parent 068dd41 commit 9521426
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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.

## [0.17.3] - 2023-12-12

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

d := gomail.NewDialer(settings.Host, settings.Port, username, settings.Password)

if settings.Secure {
if settings.TLSConfig != nil {
d.TLSConfig = settings.TLSConfig
} else {
d.TLSConfig = &tls.Config{InsecureSkipVerify: true, ServerName: settings.Host}
}

if settings.Secure {
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 9521426

Please sign in to comment.