email icon indicating copy to clipboard operation
email copied to clipboard

SSL/TLS communication isn't possible when using Pool

Open ifraixedes opened this issue 6 years ago • 6 comments

I tried to use the the Pool for sending emails to a SMTP server which offers SSL/TLS connections (not STARTTLS) and the pool.Send hangs on pool.build; that doesn't happen with Email.SendWithTLS because it uses the TLS package to dial the connection.

Hence the pool type cannot send emails using SSL/TLS connections, only send emails on unencrypted connections or encrypted ones through STARTTLS.

On the other hand, in ab implementation of a function which checks SMTP server connections which I've done, I deal differently. When the server advertise the STARTTLS connection, there is no need to dial a TLS connection, a unencrypted dial (net.Dial) works and after, it's the client.StartTLS which upgrades the connection, that's mostly is how the pool works. The thing is that it differs from the implementation of Email.SendWithTLS function, which always dial the connection with TLS independently if STARTTLS is available or not.

I cannot say if that's an issue or not, because I haven't used the Email.SendWithTLS of this package, so I'm mostly reporting as an insight.

ifraixedes avatar Dec 21 '18 12:12 ifraixedes

Pool.Send hangs on pool.build because use (net.Dial) on TLS connection. the pool builder try startTLS after that

KasterZhang avatar Aug 24 '20 10:08 KasterZhang

Hello, I believe this issue is still present. I hit it with https://github.com/slurdge/goeland/issues/3 and while I can provide a flag to have explicit SSL, I believe it wouldn't work with pools.

I think a fix would be to have the pool have an ExplicitSSL (or ExplicitTLS) member and the dial would be done by the appropriate mechanism in build. Thoughts ?

slurdge avatar Feb 15 '21 18:02 slurdge

I'm having the same problem as you, using pool to send emails with :sent error:timed out, sending without pool works fine, I don't think pool is working properly!

jeefs avatar Aug 08 '23 09:08 jeefs

@jeefs Can you give me the two config, the one that works and the one that doesn't work ?

slurdge avatar Aug 08 '23 10:08 slurdge

@slurdge I've switched to the official package net/stmp to send emails and use ssl support for encrypted emails, no problems so far!

jeefs avatar Aug 10 '23 05:08 jeefs

I gave up using pooled connections

jeefs avatar Aug 10 '23 05:08 jeefs