xhit / go-simple-mail

Golang package for send email. Support keep alive connection, TLS and SSL. Easy for bulk SMTP.
MIT License
650 stars 102 forks source link

TLS handshake failure when used with go 1.22.0 #100

Closed fosmjo closed 7 months ago

fosmjo commented 8 months ago

I'm using v2.16.0 with go 1.22.0. An error occurred when I call SMTPServer.Connect(), here is the error message:

connect to smtp server: Mail Error on dialing with encryption type SSL/TLS: remote error: tls: handshake failure

It works with go 1.21.6.

xhit commented 7 months ago

Thanks for the report, I will investigate this.

fosmjo commented 7 months ago

I've solved the problem. According to go1.22 release notes, crypto/tls no longer offers cipher suites that don't support ECDHE, and our mail server only supports cipher suites that support RSA, the TLS handshake failed. One of the solutions is to add support for RSA cipher suites with the tlsrsakex=1 GODEBUG setting, another one is to add cipher suites that support RSA manually by using tls.Config.

xhit commented 7 months ago

Perfect @fosmjo! I will pin this issue to inform other devs. Thanks for the research!