You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
yes
What did you do?
Attempt to use libraries which build upon net/SMTP, or use net/SMTP itself, in order to send emails over SMTP and you will quickly realize that having different allowed timeouts for different stages of the connection is not supported by default using net/SMTP. I have not explored using a custom Client as a workaround, but other standard libraries like Python's smtplib support timeouts by default as function arguments. and even using a custom Client doesn't seem like it would allow different timeouts for different stages of the SMTP process.
What did you expect to see?
c, err := smtp.Dial("mail.example.com:25", timeout_in_seconds)
if err != nil {
log.Fatal(err)
}
...
_, err = fmt.Fprintf(wc, "This is the email body", timeout_in_seconds)
if err != nil {
log.Fatal(err)
}
err = wc.Close(timeout_in_seconds)
if err != nil {
log.Fatal(err)
}
What did you see instead?
c, err := smtp.Dial("mail.example.com:25")
if err != nil {
log.Fatal(err)
}
...
_, err = fmt.Fprintf(wc, "This is the email body")
if err != nil {
log.Fatal(err)
}
err = wc.Close()
if err != nil {
log.Fatal(err)
}
If my suggested behavior is desired, I would be happy to make this improvement myself
The text was updated successfully, but these errors were encountered:
Per the package documentation at https://golang.org/pkg/net/smtp/, net/smtp is frozen and is not accepting new features. In addition, changing the signature of existing functions would be a violation of the Go 1 compatibility promise.
Please use an alternative package if you need this functionality.
It's painful, but you can work around this limitation by specifying an existing net.Conn to smtp.NewClient, and calling the appropriate (net.Conn).Set*Deadline method before calling the *smtp.Client method that you want to have a timeout apply to. Just remember to clear the timeout afterwards (as needed) by calling (net.Conn).Set*Deadline(time.Time{}).
What version of Go are you using (
go version
)?all versions
Does this issue reproduce with the latest release?
yes
What did you do?
Attempt to use libraries which build upon net/SMTP, or use net/SMTP itself, in order to send emails over SMTP and you will quickly realize that having different allowed timeouts for different stages of the connection is not supported by default using net/SMTP. I have not explored using a custom Client as a workaround, but other standard libraries like Python's smtplib support timeouts by default as function arguments. and even using a custom Client doesn't seem like it would allow different timeouts for different stages of the SMTP process.
What did you expect to see?
What did you see instead?
If my suggested behavior is desired, I would be happy to make this improvement myself
The text was updated successfully, but these errors were encountered: