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.
I ended up spending several hours trying to make a type that would wrap the
SMTPClienttype 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 aSMTPClientbecause the email type is what sends the email inEmail.Send, by calling an an unexported internal function. This means that I need to create a specialEmailProviderwhich returns a new type embeddingEmailso that I can wrapEmail.SendandEmail.SendEnvelopeFromto track theSMTPClientwith a mutex and reset the loop. AlsoSMTPClienthas an exportedClientfield, which returns the unexported internalsmtpClienttype, which is unfortunately useless. So I cannot have theSMTPServerreconnect the internalsmtpClient, and I must useEmailProviderto 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
EmailProviderthat wraps the client and server objects to re-create it when necessary.