diff options
author | Robin Jarry <robin@jarry.cc> | 2024-07-12 16:02:38 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-07-15 22:39:12 +0200 |
commit | d960b8d2caa689521d9bef950ee0ab23862c9f9e (patch) | |
tree | 5be6e44e93a73e4d5160c0afb7c4e0757efccc65 /lib/send/smtp.go | |
parent | 017c5468de4fd515b4dc05d70e372808fd98fb88 (diff) | |
download | aerc-d960b8d2caa689521d9bef950ee0ab23862c9f9e.tar.gz |
smtp: take smtp-domain into account for tls connections
smtp-domain is ignored when using smtps:// transport. It is only
configured for clear text and STARTTLS connections.
Also use it for TLS encrypted connections.
Fixes: c10cb370bb94 ("config: add option for SMTP HELO/EHLO local domain")
Changelog-fixed: `smtp-domain` is now properly taken into account
for TLS connections.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Tristan Partin <tristan@partin.io>
Diffstat (limited to 'lib/send/smtp.go')
-rw-r--r-- | lib/send/smtp.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/send/smtp.go b/lib/send/smtp.go index b1679014..77406fbb 100644 --- a/lib/send/smtp.go +++ b/lib/send/smtp.go @@ -39,7 +39,7 @@ func connectSmtp(starttls bool, host string, domain string) (*smtp.Client, error return conn, nil } -func connectSmtps(host string) (*smtp.Client, error) { +func connectSmtps(host string, domain string) (*smtp.Client, error) { serverName := host if !strings.ContainsRune(host, ':') { host += ":465" // Default to smtps port @@ -52,6 +52,13 @@ func connectSmtps(host string) (*smtp.Client, error) { if err != nil { return nil, errors.Wrap(err, "smtp.DialTLS") } + if domain != "" { + err := conn.Hello(domain) + if err != nil { + conn.Close() + return nil, errors.Wrap(err, "Hello") + } + } return conn, nil } @@ -85,7 +92,7 @@ func newSmtpSender( case "smtp+insecure": conn, err = connectSmtp(false, uri.Host, domain) case "smtps": - conn, err = connectSmtps(uri.Host) + conn, err = connectSmtps(uri.Host, domain) default: return nil, fmt.Errorf("not a smtp protocol %s", protocol) } |