aboutsummaryrefslogtreecommitdiffstats
path: root/lib/send/smtp.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-02-26 11:07:49 +0100
committerRobin Jarry <robin@jarry.cc>2024-04-02 22:21:50 +0200
commit7c789624d7da0a45c33519ff10830e6c1b97dd1e (patch)
tree802b2cb8b5500ea729009037e8dd5197cf96f4e2 /lib/send/smtp.go
parent6ffc0ed5991bef69a50cbc22647af0a6a0e0a895 (diff)
downloadaerc-7c789624d7da0a45c33519ff10830e6c1b97dd1e.tar.gz
mod: update all dependencies
Patch produced with the following commands: go mod edit -dropreplace=golang.org/x/crypto go get -t -u go mod tidy I dropped the replace of x/crypto. The only use for the fork from ProtonMail is for openpgp which has been deprecated by the official implementation. And aerc explicitly uses the correct import path where needed. go-smtp update was a bit harsh. The API was changed completely. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Diffstat (limited to 'lib/send/smtp.go')
-rw-r--r--lib/send/smtp.go27
1 files changed, 9 insertions, 18 deletions
diff --git a/lib/send/smtp.go b/lib/send/smtp.go
index 2cc53d25..b1679014 100644
--- a/lib/send/smtp.go
+++ b/lib/send/smtp.go
@@ -19,32 +19,23 @@ func connectSmtp(starttls bool, host string, domain string) (*smtp.Client, error
} else {
serverName = host[:strings.IndexRune(host, ':')]
}
- conn, err := smtp.Dial(host)
+ var conn *smtp.Client
+ var err error
+ if starttls {
+ conn, err = smtp.DialStartTLS(host, &tls.Config{ServerName: serverName})
+ } else {
+ conn, err = smtp.Dial(host)
+ }
if err != nil {
return nil, errors.Wrap(err, "smtp.Dial")
}
if domain != "" {
err := conn.Hello(domain)
if err != nil {
- return nil, errors.Wrap(err, "Hello")
- }
- }
- if starttls {
- if sup, _ := conn.Extension("STARTTLS"); !sup {
- err := errors.New("STARTTLS requested, but not supported " +
- "by this SMTP server. Is someone tampering with your " +
- "connection?")
- conn.Close()
- return nil, err
- }
- if err = conn.StartTLS(&tls.Config{
- ServerName: serverName,
- }); err != nil {
conn.Close()
- return nil, errors.Wrap(err, "StartTLS")
+ return nil, errors.Wrap(err, "Hello")
}
}
-
return conn, nil
}
@@ -122,7 +113,7 @@ func newSmtpSender(
return nil, errors.Wrap(err, "conn.Mail")
}
for _, rcpt := range rcpts {
- if err := s.conn.Rcpt(rcpt.Address); err != nil {
+ if err := s.conn.Rcpt(rcpt.Address, nil); err != nil {
conn.Close()
return nil, errors.Wrap(err, "conn.Rcpt")
}