Skip to content

net/smtp: SendMail blocked at smtp.Client.StartTLS #67867

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

Closed
hiroyukki opened this issue Jun 7, 2024 · 5 comments
Closed

net/smtp: SendMail blocked at smtp.Client.StartTLS #67867

hiroyukki opened this issue Jun 7, 2024 · 5 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@hiroyukki
Copy link

hiroyukki commented Jun 7, 2024

Go version

go version go1.20.13 windows/386

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=386
set GOBIN=
set GOCACHE=C:\Users\jiayi\AppData\Local\go-build
set GOENV=C:\Users\jiayi\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\gopath
set GOPRIVATE=
set GOPROXY=https://goproxy.io
set GOROOT=D:\Programs\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Programs\go\pkg\tool\windows_386
set GOVCS=
set GOVERSION=go1.20.13
set GCCGO=gccgo
set GO386=sse2
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=E:\libgx\go\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m32 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\jiayi\AppData\Local\Temp\go-build1503534736=/tmp/go-build -gno-record-gcc-switches

What did you do?

I send mail with net/smtp, some smtp server seems incompatible, my code:

func main() {
from := "[email protected]"
to := []string{"[email protected]"}
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

@mknyszek mknyszek changed the title net/smtp SendMail blocked at smtp.Client.StartTLS net/smtp: SendMail blocked at smtp.Client.StartTLS Jun 7, 2024
@mknyszek
Copy link
Contributor

mknyszek commented Jun 7, 2024

This may be a long-shot but CC @bradfitz via https://dev.golang.org/owners. Maybe also CC @neild? Not sure.

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 7, 2024
@mknyszek mknyszek added this to the Backlog milestone Jun 7, 2024
@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 15, 2024
@rsc
Copy link
Contributor

rsc commented Jun 28, 2024

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?

@gopherbot
Copy link
Contributor

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2024
@hiroyukki
Copy link
Author

hiroyukki commented Jul 22, 2024

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?

seems not work, pending on StartTLS until timeout
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants