Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[epic] client: implement smtp.Transport as an analogy to net/http.Transport #154

Closed
kayrus opened this issue Jul 22, 2021 · 3 comments
Closed

Comments

@kayrus
Copy link
Contributor

kayrus commented Jul 22, 2021

Current SMTP client implementation is not optimal. It acts like HTTP/1.0: one request per connection.
I'd like to see an SMTP client, which will have an SMTP transport by an analogy to http.Client and http.Transport.

Transport should allow to perform a RoundTripper method, reuse idle connections, have a map of connections per host, efficiently reuse established AUTH sessions to send messages within the ​same auth session when possible, etc.

P.S. I know this is a big task, and it will require a lot of effort. But at the end it will give a similar flexibility as net/http package give. I appreciate objections, feedback, suggestions.

Reference emersion/go-smtp-proxy#9

@emersion
Copy link
Owner

It acts like HTTP/1.0: one request per connection.

Nothing stops you from sending multiple messages with a single Client.

HTTP is also a bit different because it's stateless. SMTP is stateful.

Even if this was possible, I'm not sure I like the added complexity.

@foxcpp
Copy link
Collaborator

foxcpp commented Jul 22, 2021

Connection pooling is non-trivial due to SMTP stateful nature. I believe this is something that is best implemented by library users taking into consideration what is important for their own implementation.

FWIW, here is how connection pooling for MX is implemented in maddy:

Note that it does not manage authentication in any way.

@emersion
Copy link
Owner

Closing because I think this is out of scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants