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?
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)}
Your ISP might be blocking port 25. I have to use port 587 to googles smtp server to connect.