Implement reconnect or reconnect helper from #23
flowchartsman opened this issue · 1 comments
I ended up spending several hours trying to make a type that would wrap the SMTPClient
type and do the NOOP sending to implement the suggestion in this comment before I realized there was no easy way to track the last time an email was sent for the timer, and you cannot do that by wrapping a SMTPClient
because the email type is what sends the email in Email.Send
, by calling an an unexported internal function. This means that I need to create a special EmailProvider
which returns a new type embedding Email
so that I can wrap Email.Send
and Email.SendEnvelopeFrom
to track the SMTPClient
with a mutex and reset the loop. Also SMTPClient
has an exported Client
field, which returns the unexported internal smtpClient
type, which is unfortunately useless. So I cannot have the SMTPServer
reconnect the internal smtpClient
, and I must use EmailProvider
to do that. It's a bit convoluted and not nearly as easy as the solution in #23 would suggest.
It would be nice if there was a way to do this in the library, or if you could provide a type like my EmailProvider
that wraps the client and server objects to re-create it when necessary.
Yes, need to be done in the package, I can restore an early implementation from older laptop that currently works in production.
Currently I'm too busy, I hope have time in January 2023.
I remember the solution was very simple in the package. Doesn't need any change or new type, current code will be working and developer can send emails in same connection in bulk without need to make a NOOP or reconnect, only using the same connection.