mirror of https://gitee.com/answerdev/answer.git
feat(email): add SKIP_SMTP_TLS_VERIFY ENV for allow insecure certification. #271
This commit is contained in:
parent
0aa98fb2af
commit
ac96115b76
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue