From 069c77bebd81bde7cccbf8a90c4d5eed62014377 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 26 Jul 2024 11:42:11 +0200 Subject: [PATCH] email: update StartTLS usage per go-smtp changes --- email/send.go | 11 ++--------- go.mod | 4 ++-- go.sum | 4 ++++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/email/send.go b/email/send.go index 07b5c6058ff4c6865d32821ea5259b5842c576e6..2c75dac82f2a0ca032ec9145248d7fed6e152eb3 100644 --- a/email/send.go +++ b/email/send.go @@ -83,6 +83,8 @@ func mailSetup(ctx context.Context) (*smtp.Client, *mail.Address, error) { if mailconf.enctype == "tls" { c, err = smtp.DialTLS(addr, nil) + } else if mailconf.enctype == "starttls" { + c, err = smtp.DialStartTLS(addr, nil) } else { c, err = smtp.Dial(addr) } @@ -94,15 +96,6 @@ func mailSetup(ctx context.Context) (*smtp.Client, *mail.Address, error) { return nil, nil, err } - if mailconf.enctype == "starttls" { - if ok, _ := c.Extension("STARTTLS"); !ok { - panic(fmt.Errorf("smtp: server doesn't support STARTTLS")) - } - if err = c.StartTLS(nil); err != nil { - return nil, nil, err - } - } - if mailconf.authtype == "plain" { auth := sasl.NewPlainClient("", mailconf.user, mailconf.pass) if ok, _ := c.Extension("AUTH"); !ok { diff --git a/go.mod b/go.mod index 5c7e8488d27017f160fbb0480e3988810189e090..d8d198e1da106f03b14bfbb85d60fb560ca954fe 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 github.com/emersion/go-message v0.16.0 github.com/emersion/go-pgpmail v0.2.0 - github.com/emersion/go-sasl v0.0.0-20220912192320-0145f2c60ead - github.com/emersion/go-smtp v0.18.0 + github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 + github.com/emersion/go-smtp v0.21.3 github.com/fernet/fernet-go v0.0.0-20211208181803-9f70042a33ee github.com/go-chi/chi/v5 v5.0.10 github.com/go-redis/redis/v8 v8.11.5 diff --git a/go.sum b/go.sum index fbe6a8c50b7dd634df2559d393ceb1fe02ad830b..b1fb9dfb4c70ca459d6320e386e9f45df901d72a 100644 --- a/go.sum +++ b/go.sum @@ -101,8 +101,12 @@ github.com/emersion/go-pgpmail v0.2.0/go.mod h1:8mQ8Rpn+w28DDaiP8HvJuZjSAymaWr87 github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ= github.com/emersion/go-sasl v0.0.0-20220912192320-0145f2c60ead h1:fI1Jck0vUrXT8bnphprS1EoVRe2Q5CKCX8iDlpqjQ/Y= github.com/emersion/go-sasl v0.0.0-20220912192320-0145f2c60ead/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ= +github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 h1:hH4PQfOndHDlpzYfLAAfl63E8Le6F2+EL/cdhlkyRJY= +github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ= github.com/emersion/go-smtp v0.18.0 h1:lrVQqB0JdxYjC8CsBt55pSwB756bRRN6vK0DSr0pXfM= github.com/emersion/go-smtp v0.18.0/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ= +github.com/emersion/go-smtp v0.21.3 h1:7uVwagE8iPYE48WhNsng3RRpCUpFvNl39JGNSIyGVMY= +github.com/emersion/go-smtp v0.21.3/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ= github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 h1:IbFBtwoTQyw0fIM5xv1HF+Y+3ZijDR839WMulgxCcUY= github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=