douhuike3199
douhuike3199
2015-05-20 07:20
浏览 103
已采纳

smtp.Dial(“ ASPMX.L.GOOGLE.COM:25”)连接错误; 但是油灰连接有效

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?

图片转代码服务由CSDN问答提供 功能建议

使用Go和 smtp.Dial ,\甚至 net.Dial , 我收到错误消息: \ n

拨号tcp 64.233.169.27:25:ConnectEx tcp:连接尝试失败 ,因为一段时间后连接对象未正确响应 ,或者由于连接的主机已经建立连接而失败 无法响应。

从以下代码开始:

  mxClient,err:= smtp.Dial(  “ ASPMX.L.GOOGLE.COM:25")
if err!= nil {
 fmt.Println(err)
} 
   
 
 

我不做什么 我不知道我可以使用端口25上的腻子在不使用TLS的情况下连接和发送命令( HELO 等)。 如果是由于无法进行连接的限制, is 在Go中建立像腻子这样的原始套接字连接的推荐方法?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doulechou0700
    doulechou0700 2015-05-20 08:46
    已采纳

    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)}
    
    点赞 评论
  • dongming5444
    dongming5444 2015-05-20 17:11

    Your ISP might be blocking port 25. I have to use port 587 to googles smtp server to connect.

    点赞 评论

相关推荐