-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mailotp code comparison was failing (#440)
- Added option to disable STARTTLS for smtp dialer - Added additional e2e test to validate the flow Signed-off-by: Kush Sharma <[email protected]>
- Loading branch information
1 parent
c5c9d22
commit 96a5885
Showing
10 changed files
with
143 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,12 @@ app: | |
smtp_insecure: true | ||
headers: | ||
from: "[email protected]" | ||
# policy to use when establishing a connection. Defaults to mandatory_start. | ||
# Possible values are: | ||
# opportunistic: Use STARTTLS if the server supports it, otherwise connect without encryption. | ||
# mandatory: Always use STARTTLS. | ||
# no: Never use STARTTLS. | ||
smtp_tls_policy: "mandatory" | ||
db: | ||
driver: postgres | ||
url: postgres://frontier:@localhost:5432/frontier?sslmode=disable | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
package mailer | ||
|
||
import ( | ||
"strings" | ||
|
||
"gopkg.in/mail.v2" | ||
) | ||
|
||
type Config struct { | ||
SMTPHost string `yaml:"smtp_host" mapstructure:"smtp_host"` | ||
SMTPPort int `yaml:"smtp_port" mapstructure:"smtp_port"` | ||
SMTPUsername string `yaml:"smtp_username" mapstructure:"smtp_username"` | ||
SMTPPassword string `yaml:"smtp_password" mapstructure:"smtp_password"` | ||
SMTPInsecure bool `yaml:"smtp_insecure" mapstructure:"smtp_insecure" default:"true"` | ||
Headers map[string]string `yaml:"headers" mapstructure:"headers"` | ||
|
||
// SMTP TLS policy to use when establishing a connection. | ||
// Defaults to MandatoryStartTLS. | ||
// Possible values are: | ||
// opportunistic: Use STARTTLS if the server supports it, otherwise connect without encryption. | ||
// mandatory: Always use STARTTLS. | ||
// none: Never use STARTTLS. | ||
SMTPTLSPolicy string `yaml:"smtp_tls_policy" mapstructure:"smtp_tls_policy" default:"mandatory"` | ||
} | ||
|
||
func (c Config) TLSPolicy() mail.StartTLSPolicy { | ||
switch strings.ToLower(c.SMTPTLSPolicy) { | ||
case "opportunistic": | ||
return mail.OpportunisticStartTLS | ||
case "mandatory": | ||
return mail.MandatoryStartTLS | ||
case "none": | ||
return mail.NoStartTLS | ||
} | ||
return mail.MandatoryStartTLS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters