Skip to content

Commit 87ef545

Browse files
committed
fix(reporter/email): do not use Client.StartTLS
1 parent 4559da3 commit 87ef545

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

reporter/email.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,11 @@ func (e *emailSender) sendMail(smtpServerAddr, message string) (err error) {
9292
var c *smtp.Client
9393
var auth sasl.Client
9494
emailConf := e.conf
95-
//TLS Config
9695
tlsConfig := &tls.Config{
9796
ServerName: emailConf.SMTPAddr,
9897
}
9998
switch emailConf.SMTPPort {
10099
case "465":
101-
//New TLS connection
102100
c, err = smtp.DialTLS(smtpServerAddr, tlsConfig)
103101
if err != nil {
104102
return xerrors.Errorf("Failed to create TLS connection to SMTP server: %w", err)
@@ -111,16 +109,17 @@ func (e *emailSender) sendMail(smtpServerAddr, message string) (err error) {
111109
}
112110
defer c.Close()
113111

114-
if err = c.Hello("localhost"); err != nil {
115-
return xerrors.Errorf("Failed to send Hello command: %w", err)
116-
}
117-
118112
if ok, _ := c.Extension("STARTTLS"); ok {
119-
if err := c.StartTLS(tlsConfig); err != nil {
120-
return xerrors.Errorf("Failed to STARTTLS: %w", err)
113+
c, err = smtp.DialStartTLS(smtpServerAddr, tlsConfig)
114+
if err != nil {
115+
return xerrors.Errorf("Failed to create STARTTLS connection to SMTP server: %w", err)
121116
}
122117
}
123118

119+
if err = c.Hello("localhost"); err != nil {
120+
return xerrors.Errorf("Failed to send Hello command: %w", err)
121+
}
122+
124123
if ok, param := c.Extension("AUTH"); ok {
125124
authList := strings.Split(param, " ")
126125
auth = e.newSaslClient(authList)

0 commit comments

Comments
 (0)