New feature: SMTP connection may use client certificate.
New config keys in [mailer] section: - CERT_FILE: path to a certificate file. - KEY_FILE: path to a key file.
This commit is contained in:
parent
485ea6f14f
commit
8a6c86644e
|
@ -72,9 +72,15 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cert, err := tls.LoadX509KeyPair(settings.CertFile, settings.KeyFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
tlsconfig := &tls.Config{
|
tlsconfig := &tls.Config{
|
||||||
InsecureSkipVerify: settings.SkipVerify,
|
InsecureSkipVerify: settings.SkipVerify,
|
||||||
ServerName: host,
|
ServerName: host,
|
||||||
|
Certificates: []tls.Certificate{cert},
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := net.Dial("tcp", net.JoinHostPort(host, port))
|
conn, err := net.Dial("tcp", net.JoinHostPort(host, port))
|
||||||
|
|
|
@ -451,6 +451,7 @@ type Mailer struct {
|
||||||
From string
|
From string
|
||||||
User, Passwd string
|
User, Passwd string
|
||||||
SkipVerify bool
|
SkipVerify bool
|
||||||
|
CertFile, KeyFile string
|
||||||
}
|
}
|
||||||
|
|
||||||
type OauthInfo struct {
|
type OauthInfo struct {
|
||||||
|
@ -483,6 +484,8 @@ func newMailService() {
|
||||||
User: sec.Key("USER").String(),
|
User: sec.Key("USER").String(),
|
||||||
Passwd: sec.Key("PASSWD").String(),
|
Passwd: sec.Key("PASSWD").String(),
|
||||||
SkipVerify: sec.Key("SKIP_VERIFY").MustBool(),
|
SkipVerify: sec.Key("SKIP_VERIFY").MustBool(),
|
||||||
|
CertFile: sec.Key("CERT_FILE").String(),
|
||||||
|
KeyFile: sec.Key("KEY_FILE").String(),
|
||||||
}
|
}
|
||||||
MailService.From = sec.Key("FROM").MustString(MailService.User)
|
MailService.From = sec.Key("FROM").MustString(MailService.User)
|
||||||
log.Info("Mail Service Enabled")
|
log.Info("Mail Service Enabled")
|
||||||
|
|
Loading…
Reference in New Issue