diff --git a/cmd/channel/email/main.go b/cmd/channel/email/main.go index f5cf7c082..e03fb2ea1 100644 --- a/cmd/channel/email/main.go +++ b/cmd/channel/email/main.go @@ -68,6 +68,8 @@ func (ch *Email) Send(reversePath string, recipients []string, msg []byte) error if ch.Encryption == EncryptionTLS { client, err = smtp.DialTLS(ch.GetServer(), nil) + } else if ch.Encryption == EncryptionStartTLS { + client, err = smtp.DialStartTLS(ch.GetServer(), nil) } else { client, err = smtp.Dial(ch.GetServer()) } @@ -76,12 +78,6 @@ func (ch *Email) Send(reversePath string, recipients []string, msg []byte) error } defer func() { _ = client.Close() }() - if ch.Encryption == EncryptionStartTLS { - if err = client.StartTLS(nil); err != nil { - return err - } - } - if ch.Password != "" { if err = client.Auth(sasl.NewPlainClient("", ch.User, ch.Password)); err != nil { return err