How to run telnet command?

144 views
Skip to first unread message

Postgres Hero

unread,
Nov 2, 2022, 1:37:28 PM11/2/22
to golang-nuts
Hi All,

I am naive in Golang :), so please forgive me if my question seems silly.

I am trying to achieve the following telnet command in Go, but in vain.

"telnet mx mydomain.com 25"

I found a package here – github.com/reiver/go-telnet. However, I could not find a way to execute the aforementioned command.

Could someone shed some light on this?

Thanks in advance.

Brian Candler

unread,
Nov 2, 2022, 4:45:35 PM11/2/22
to golang-nuts
I think what you really want is not to use telnet, but to connect to a mailserver on port 25.  To establish a TCP connection in Go, you should use net.Dial. See: https://pkg.go.dev/net

If you actually want to send mail, there are higher level approaches which will take care of a lot of the details for you, for example: https://pkg.go.dev/net/smtp
Reply all
Reply to author
Forward
0 new messages