You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/05/27 08:03:45 UTC

(incubator-answer) 02/02: setting ssl to false

This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 2913640a86b8c72fb7e7b61e197bab477280e07d
Author: sy-records <52...@qq52o.cn>
AuthorDate: Mon May 20 16:18:16 2024 +0800

    setting ssl to false
---
 internal/service/export/email_service.go | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/internal/service/export/email_service.go b/internal/service/export/email_service.go
index beec645d..03d9c182 100644
--- a/internal/service/export/email_service.go
+++ b/internal/service/export/email_service.go
@@ -74,7 +74,7 @@ type EmailConfig struct {
 	FromName           string `json:"from_name"`
 	SMTPHost           string `json:"smtp_host"`
 	SMTPPort           int    `json:"smtp_port"`
-	Encryption         string `json:"encryption"` // "" SSL
+	Encryption         string `json:"encryption"` // "" SSL TLS
 	SMTPUsername       string `json:"smtp_username"`
 	SMTPPassword       string `json:"smtp_password"`
 	SMTPAuthentication bool   `json:"smtp_authentication"`
@@ -84,6 +84,10 @@ func (e *EmailConfig) IsSSL() bool {
 	return e.Encryption == "SSL"
 }
 
+func (e *EmailConfig) IsTLS() bool {
+	return e.Encryption == "TLS"
+}
+
 // SaveCode save code
 func (es *EmailService) SaveCode(ctx context.Context, code, codeContent string) {
 	err := es.emailRepo.SetCode(ctx, code, codeContent, 10*time.Minute)
@@ -135,6 +139,9 @@ func (es *EmailService) Send(ctx context.Context, toEmailAddr, subject, body str
 	if ec.IsSSL() {
 		d.SSL = true
 	}
+	if ec.IsTLS() {
+		d.SSL = false
+	}
 	if len(os.Getenv("SKIP_SMTP_TLS_VERIFY")) > 0 {
 		d.TLSConfig = &tls.Config{ServerName: d.Host, InsecureSkipVerify: true}
 	}