jordan-wright / email

Robust and flexible email library for Go
MIT License
2.61k stars 324 forks source link

Would a v4 PR with better pooling + breaking changes be considered? #110

Closed knadh closed 4 years ago

knadh commented 4 years ago

Hi @jordan-wright, Been using email in a bunch of places, and it works well, except for a couple (serious) problems. It does not always handle connection failures gracefully, and it has no mechanism to timeout idle connections. This is a critical issue with providers like SES that kill long standing connections, while the pool remains oblivious, failing new messages as they come. This behaviour also leads to providers throttling further connections.

I've a fork under development with minor cosmetic changes to email.go, with a whole new pooling mechanism (completely new pool.go). The pool is maintained in a channel like it is right now, and there is a goroutine that periodically sweeps idle connections and closes them.

There is no change to the Send() API, but New() takes an options struct instead of a list of arguments, breaking compatibility with the existing versions.

Would you be open to reviewing and merging this as a major breaking version, v4?

knadh commented 4 years ago

I ended up releasing the fork at knadh/smtppool. It's a new pool lib with the e-mail parsing/preparation forked from this lib. Handles idle timeouts, re-connections, and message retries on failures, gracefully.

Thanks for this lib @jordan-wright!