I want to use socks5 for connect to smtp

//its work
...
host := "mx.yandex.ru"
c, err := smtp.Dial(host + ":2525")
...

//its not work
...
import "golang.org/x/net/proxy"
...
dialer, _:= proxy.SOCKS5("tcp", p, nil, proxy.Direct)
_, err = dialer.Dial("tcp", "mx.yandex.ru:2525")
if err != nil {
    fmt.Printf("ERROR %v\n", err)
    os.Exit(1)
}

ERROR socks connect tcp x.x.x.x:y->mx.yandex.ru:2525: unknown error network unreachable

But this working. Why?

dialer, _:= proxy.SOCKS5("tcp", p, nil, proxy.Direct)
_, err = dialer.Dial("tcp", "yandex.ru:80")
if err != nil {
    fmt.Printf("ERROR %v\n", err)
    os.Exit(1)
}

0 Answers