Click or drag to resize
MimeKit

ProxyClient Class

An abstract proxy client base class.
Inheritance Hierarchy

Namespace: MailKit.Net.Proxy
Assembly: MailKit (in MailKit.dll) Version: 4.7.1
Syntax
C#
public abstract class ProxyClient : IProxyClient

The ProxyClient type exposes the following members.

Constructors
 NameDescription
Protected methodProxyClient(String, Int32) Initializes a new instance of the ProxyClient class.
Protected methodProxyClient(String, Int32, NetworkCredential) Initializes a new instance of the ProxyClient class.
Top
Properties
 NameDescription
Public propertyLocalEndPoint Get or set the local IP end point to use when connecting to a remote host.
Public propertyProxyCredentials Gets the proxy credentials.
Public propertyProxyHost Get the proxy host.
Public propertyProxyPort Get the proxy port.
Top
Methods
 NameDescription
Public methodConnect(String, Int32, CancellationToken) Connect to the target host.
Public methodConnect(String, Int32, Int32, CancellationToken) Connect to the target host.
Public methodConnectAsync(String, Int32, CancellationToken) Asynchronously connect to the target host.
Public methodConnectAsync(String, Int32, Int32, CancellationToken) Asynchronously connect to the target host.
Public methodEquals
(Inherited from Object)
Protected methodFinalize
(Inherited from Object)
Public methodGetHashCode
(Inherited from Object)
Public methodGetType
(Inherited from Object)
Protected methodMemberwiseClone
(Inherited from Object)
Public methodToString
(Inherited from Object)
Top
Remarks
A proxy client can be used to connect to a service through a firewall that would otherwise be blocked.
Example
C#
public static void SendMessageViaProxy (MimeMessage message)
{
    using (var client = new SmtpClient ()) {
        client.ProxyClient = new Socks5Proxy ("socks5.proxy.com", 1080, new NetworkCredentials ("proxyUserName", "proxyPassword"));
        client.Connect ("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
        client.Authenticate ("username", "password");

        client.Send (message);

        client.Disconnect (true);
    }
}
See Also