Skip to content

Commit 3786b43

Browse files
yhabteabjulianbrost
authored andcommitted
Fix usage of unexported smtp#StartTLS() with go-smtp >= 0.21.0
1 parent 57ea227 commit 3786b43

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

cmd/channel/email/main.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,21 @@ func (ch *Email) Send(reversePath string, recipients []string, msg []byte) error
6666
err error
6767
)
6868

69-
if ch.Encryption == EncryptionTLS {
69+
switch ch.Encryption {
70+
case EncryptionStartTLS:
71+
client, err = smtp.DialStartTLS(ch.GetServer(), nil)
72+
case EncryptionTLS:
7073
client, err = smtp.DialTLS(ch.GetServer(), nil)
71-
} else {
74+
case EncryptionNone:
7275
client, err = smtp.Dial(ch.GetServer())
76+
default:
77+
return fmt.Errorf("unsupported mail encryption type %q", ch.Encryption)
7378
}
7479
if err != nil {
7580
return err
7681
}
7782
defer func() { _ = client.Close() }()
7883

79-
if ch.Encryption == EncryptionStartTLS {
80-
if err = client.StartTLS(nil); err != nil {
81-
return err
82-
}
83-
}
84-
8584
if ch.Password != "" {
8685
if err = client.Auth(sasl.NewPlainClient("", ch.User, ch.Password)); err != nil {
8786
return err

0 commit comments

Comments
 (0)