@@ 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 {
@@ 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
@@ 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=