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

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?

  • 写回答

2条回答 默认 最新

  • 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)}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 对于这个问题的代码运行
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败