go-gomail / gomail

The best way to send emails in Go.
MIT License
4.32k stars 572 forks source link

Break out SMTP Client Reset Method #79

Open fjace05 opened 7 years ago

fjace05 commented 7 years ago

This is a pull request to remedy Issue #77. It breaks out the already existent Reset method on the Go Lang net/smtp Client library. For this fix, the method is added to the SenderCloser interface to make it accessible when running the "Daemon Mode". This will allow users to reset the channel instead of completely closing and reopening the channel after an error occurs while sending a message.

jordan-wright commented 6 years ago

I hope this can be considered to be merged. The primary use case for me is to keep the existing connection when sending a large number of emails and one of them receives an error.

I've seen cases where after this error is received, calling Send with the same SendCloser results in another error since the state is out of sync.

For now, I'm having to copy the smtpSender and expose my own Reset() method, which feels like quite a bit of duplicated code.

pedromorgan commented 6 years ago

@fjace05 Any chance you can submit as PR to the Fork so it can be merged ? https://github.com/go-mail/gomail