Socks5Client(String, Int32) Constructor

Initializes a new instance of the Socks5Client class.

Definition

Namespace: MailKit.Net.Proxy
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
public Socks5Client(
	string host,
	int port
)

Parameters

host  String
The host name of the proxy server.
port  Int32
The proxy server port.

Remarks

Initializes a new instance of the Socks5Client class.

Example

C#
                    public static void SendMessageViaProxy (MimeMessage message)
{
    using (var client = new SmtpClient ()) {
        client.ProxyClient = new Socks5Client ("socks5.proxy.com", 1080, new NetworkCredential ("proxyUserName", "proxyPassword"));
        client.Connect ("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
        client.Authenticate ("username", "password");

        client.Send (message);

        client.Disconnect (true);
    }
}
                  

Exceptions

ArgumentNullException host is .
ArgumentOutOfRangeException port is not between 1 and 65535.
ArgumentException

The host is a zero-length string.

-or-

The length of host is greater than 255 characters.

See Also