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

This commit is contained in:
LinkinStars 2023-05-17 10:35:11 +08:00
parent 0aa98fb2af
commit ac96115b76
1 changed files with 5 additions and 0 deletions

View File

@ -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 {