Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat(email): add SKIP_SMTP_TLS_VERIFY ENV for allow insecure certification. #271

LinkinStarsac96115b7659
diff --git a/internal/service/export/email_service.go b/internal/service/export/email_service.go
index 4fc9a2fa..92be3dd5 100644
--- a/internal/service/export/email_service.go
+++ b/internal/service/export/email_service.go
@@ -2,10 +2,12 @@ package export
import (
"bytes"
+ "crypto/tls"
"encoding/json"
"fmt"
"html/template"
"mime"
+ "os"
"time"
"github.com/answerdev/answer/internal/base/reason"
@@ -128,6 +130,9 @@ func (es *EmailService) Send(ctx context.Context, toEmailAddr, subject, body str
if ec.IsSSL() {
d.SSL = true
}
+ if len(os.Getenv("SKIP_SMTP_TLS_VERIFY")) > 0 {
+ d.TLSConfig = &tls.Config{ServerName: d.Host, InsecureSkipVerify: true}
+ }
if err := d.DialAndSend(m); err != nil {
log.Errorf("send email to %s failed: %s", toEmailAddr, err)
} else {