Open hiroyukki opened 3 weeks ago
This may be a long-shot but CC @bradfitz via https://dev.golang.org/owners. Maybe also CC @neild? Not sure.
Similar Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
This program works fine for me (prints StartTLS worked) using a cloud system that can dial port 25 (my home internet gets blocked by my ISP):
package main
import (
"crypto/tls"
"log"
"net/smtp"
)
func main() {
addr := "smtp.exmail.qq.com:25"
println("dial...")
c, err := smtp.Dial(addr)
if err != nil {
log.Fatal(err)
}
defer c.Close()
println("extensions?...")
if ok, _ := c.Extension("STARTTLS"); ok {
println("starttls...")
config := &tls.Config{ServerName: "smtp.exmail.qq.com"}
if err = c.StartTLS(config); err != nil {
log.Fatal(err)
}
log.Fatal("StartTLS worked")
}
log.Fatalf("no tls")
}
Does it work for you?
Go version
go version go1.20.13 windows/386
Output of
go env
in your module/workspace:What did you do?
I send mail with net/smtp, some smtp server seems incompatible, my code:
func main() { from := "test@gooxion.com" to := []string{"test2@gooxion.com"} auth := smtp.PlainAuth("", from, "wrong_pswd", "smtp.exmail.qq.com:25") fmt.Println("pre sendMail") fmt.Println(smtp.SendMail("smtp.exmail.qq.com:25", auth, from, to, []byte("hello"))) fmt.Println("post sendMail") }
What did you see happen?
smtp.SendMail blocked (at smtp.Client.StartTLS) for about 2 minutes, until socket timeout
What did you expect to see?
STMP protocol can be run normally, failed or succeeded faithfully but not hang