英文:
smtp.Dial("ASPMX.L.GOOGLE.COM:25") connection error; but putty connections work
问题
当使用Go语言和smtp.Dial
或者net.Dial
时,我遇到了以下错误:
dial tcp 64.233.169.27:25: ConnectEx tcp: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
这是由以下代码引起的:
mxClient, err := smtp.Dial("ASPMX.L.GOOGLE.COM:25")
if err != nil {
fmt.Println(err)
}
我不明白的是,我可以使用putty在25端口上连接并发送命令(如HELO
),而不使用TLS。如果这是包无法建立连接的限制,是否有一种推荐的方法在Go中建立类似putty的原始套接字连接?
英文:
When using Go and smtp.Dial
,
or even net.Dial
,
I get the error:
> dial tcp 64.233.169.27:25: ConnectEx tcp: A connection attempt failed
> because the connected party did not properly respond after a period of
> time, or established connection failed because connected host has
> failed to respond.
From this code:
mxClient, err := smtp.Dial("ASPMX.L.GOOGLE.COM:25")
if err != nil {
fmt.Println(err)
}
What I don't understand is that I can connect and send commands (HELO
, etc) using putty on port 25 without TLS.
If it's a limitation of the package not able to make the connection,
is there a recommended way to make a raw socket connection like putty in Go?
答案1
得分: 1
我在我的机器上没有看到任何错误。
package main
import (
"fmt"
"net/smtp"
)
func main() {
mxClient, err := smtp.Dial("ASPMX.L.GOOGLE.COM:25")
if err != nil {
fmt.Println(err)
}
fmt.Printf("%#v", mxClient)
}
输出结果为:
&smtp.Client{Text:(*textproto.Conn)(0xc208074000), conn:(*net.TCPConn)(0xc20802c018), tls:false, serverName:"ASPMX.L.GOOGLE.COM", ext:map[string]string(nil), auth:[]string(nil), localName:"localhost", didHello:false, helloError:error(nil)}
英文:
I don't see any error on my machine.
package main
import (
"fmt"
"net/smtp"
)
func main() {
mxClient, err := smtp.Dial("ASPMX.L.GOOGLE.COM:25")
if err != nil {
fmt.Println(err)
}
fmt.Printf("%#v", mxClient)
}
gives
&smtp.Client{Text:(*textproto.Conn)(0xc208074000), conn:(*net.TCPConn)(0xc20802c018), tls:false, serverName:"ASPMX.L.GOOGLE.COM", ext:map[string]string(nil), auth:[]string(nil), localName:"localhost", didHello:false, helloError:error(nil)}
答案2
得分: 0
您的ISP可能会阻止25号端口。我必须使用587号端口连接到谷歌的SMTP服务器。
英文:
Your ISP might be blocking port 25. I have to use port 587 to googles smtp server to connect.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论