C# Class MailKit.MailService

An abstract mail service implementation.
An abstract mail service implementation.
Inheritance: IMailService
Datei anzeigen Open project: jstedfast/MailKit Class Usage Examples

Public Methods

Method Description
Authenticate ( ICredentials credentials, CancellationToken cancellationToken = default(CancellationToken) ) : void

Authenticates using the supplied credentials.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
Authenticate ( Portable.Text.Encoding encoding, ICredentials credentials, CancellationToken cancellationToken = default(CancellationToken) ) : void

Authenticates using the supplied credentials.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
Authenticate ( Portable.Text.Encoding encoding, string userName, string password, CancellationToken cancellationToken = default(CancellationToken) ) : void

Authenticates using the specified user name and password.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
Authenticate ( string userName, string password, CancellationToken cancellationToken = default(CancellationToken) ) : void

Authenticates using the specified user name and password.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
AuthenticateAsync ( ICredentials credentials, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously authenticates using the supplied credentials.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
AuthenticateAsync ( Portable.Text.Encoding encoding, ICredentials credentials, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously authenticates using the supplied credentials.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
AuthenticateAsync ( Portable.Text.Encoding encoding, string userName, string password, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously authenticates using the specified user name and password.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
AuthenticateAsync ( string userName, string password, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously authenticates using the specified user name and password.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
Connect ( Uri uri, CancellationToken cancellationToken = default(CancellationToken) ) : void

Establish a connection to the specified mail server.

Establishes a connection to the specified mail server.

Connect ( string host, int port, SecureSocketOptions options = SecureSocketOptions.Auto, CancellationToken cancellationToken = default(CancellationToken) ) : void

Establish a connection to the specified mail server.

Establishes a connection to the specified mail server.

Connect ( string host, int port, bool useSsl, CancellationToken cancellationToken = default(CancellationToken) ) : void

Establish a connection to the specified mail server.

Establishes a connection to the specified mail server.

The useSsl argument only controls whether or not the client makes an SSL-wrapped connection. In other words, even if the useSsl parameter is false, SSL/TLS may still be used if the mail server supports the STARTTLS extension.

To disable all use of SSL/TLS, use the Connect(string,int,MailKit.Security.SecureSocketOptions,System.Threading.CancellationToken) overload with a value of SecureSocketOptions.None instead.

ConnectAsync ( Uri uri, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously establish a connection to the specified mail server.

Asynchronously establishes a connection to the specified mail server.

ConnectAsync ( string host, int port, SecureSocketOptions options = SecureSocketOptions.Auto, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously establish a connection to the specified mail server.

Asynchronously establishes a connection to the specified mail server.

ConnectAsync ( string host, int port, bool useSsl, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously establish a connection to the specified mail server.

Asynchronously establishes a connection to the specified mail server.

The useSsl argument only controls whether or not the client makes an SSL-wrapped connection. In other words, even if the useSsl parameter is false, SSL/TLS may still be used if the mail server supports the STARTTLS extension.

To disable all use of SSL/TLS, use the ConnectAsync(string,int,MailKit.Security.SecureSocketOptions,System.Threading.CancellationToken) overload with a value of SecureSocketOptions.None instead.

DefaultServerCertificateValidationCallback ( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors ) : bool

The default server certificate validation callback used when connecting via SSL or TLS.

The default server certificate validation callback considers self-signed certificates to be valid so long as the only error in the certificate chain is an untrusted root.

It should be noted that self-signed certificates may be an indication of a man-in-the-middle (MITM) attack and so it is recommended that the client implement a custom server certificate validation callback that presents the certificate to the user in some way, allowing the user to confirm or deny its validity.
Disconnect ( bool quit, CancellationToken cancellationToken = default(CancellationToken) ) : void

Disconnects the service.

If quit is true, a logout/quit command will be issued in order to disconnect cleanly.

DisconnectAsync ( bool quit, CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously disconnects the service.

If quit is true, a logout/quit command will be issued in order to disconnect cleanly.

Dispose ( ) : void

Releases all resource used by the MailService object.

Call Dispose() when you are finished using the MailService. The Dispose() method leaves the MailService in an unusable state. After calling Dispose(), you must release all references to the MailService so the garbage collector can reclaim the memory that the MailService was occupying.

NoOp ( CancellationToken cancellationToken = default(CancellationToken) ) : void

Pings the mail server to keep the connection alive.

Mail servers, if left idle for too long, will automatically drop the connection.

NoOpAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task

Asynchronously pings the mail server to keep the connection alive.

Mail servers, if left idle for too long, will automatically drop the connection.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Releases the unmanaged resources used by the MailService and optionally releases the managed resources.

Releases the unmanaged resources used by the MailService and optionally releases the managed resources.

MailService ( ) : System

Initializes a new instance of the MailKit.MailService class.

Initializes a new instance of the MailKit.MailService class.

MailService ( IProtocolLogger protocolLogger ) : System

Initializes a new instance of the MailKit.MailService class.

Initializes a new instance of the MailKit.MailService class.

OnAuthenticated ( string message ) : void

Raise the authenticated event.

Raises the authenticated event.

OnConnected ( ) : void

Raise the connected event.

Raises the connected event.

OnDisconnected ( ) : void

Raise the disconnected event.

Raises the disconnected event.

Method Details

Authenticate() public method

Authenticates using the supplied credentials.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
/// is null. /// /// The has been disposed. /// /// The is not connected or is already authenticated. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public Authenticate ( ICredentials credentials, CancellationToken cancellationToken = default(CancellationToken) ) : void
credentials ICredentials The user's credentials.
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

Authenticate() public abstract method

Authenticates using the supplied credentials.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
/// is null. /// -or- /// is null. /// /// The has been disposed. /// /// The is not connected or is already authenticated. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public abstract Authenticate ( Portable.Text.Encoding encoding, ICredentials credentials, CancellationToken cancellationToken = default(CancellationToken) ) : void
encoding Portable.Text.Encoding The encoding to use for the user's credentials.
credentials ICredentials The user's credentials.
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

Authenticate() public method

Authenticates using the specified user name and password.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
/// is null. /// -or- /// is null. /// -or- /// is null. /// /// The has been disposed. /// /// The is not connected or is already authenticated. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public Authenticate ( Portable.Text.Encoding encoding, string userName, string password, CancellationToken cancellationToken = default(CancellationToken) ) : void
encoding Portable.Text.Encoding The encoding to use for the user's credentials.
userName string The user name.
password string The password.
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

Authenticate() public method

Authenticates using the specified user name and password.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
/// is null. /// -or- /// is null. /// /// The has been disposed. /// /// The is not connected or is already authenticated. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public Authenticate ( string userName, string password, CancellationToken cancellationToken = default(CancellationToken) ) : void
userName string The user name.
password string The password.
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

AuthenticateAsync() public method

Asynchronously authenticates using the supplied credentials.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
/// is null. /// /// The has been disposed. /// /// The is not connected or is already authenticated. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public AuthenticateAsync ( ICredentials credentials, CancellationToken cancellationToken = default(CancellationToken) ) : Task
credentials ICredentials The user's credentials.
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

AuthenticateAsync() public method

Asynchronously authenticates using the supplied credentials.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
/// is null. /// -or- /// is null. /// /// The has been disposed. /// /// The is not connected or is already authenticated. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public AuthenticateAsync ( Portable.Text.Encoding encoding, ICredentials credentials, CancellationToken cancellationToken = default(CancellationToken) ) : Task
encoding Portable.Text.Encoding The encoding to use for the user's credentials.
credentials ICredentials The user's credentials.
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

AuthenticateAsync() public method

Asynchronously authenticates using the specified user name and password.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
/// is null. /// -or- /// is null. /// -or- /// is null. /// /// The has been disposed. /// /// The is not connected or is already authenticated. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public AuthenticateAsync ( Portable.Text.Encoding encoding, string userName, string password, CancellationToken cancellationToken = default(CancellationToken) ) : Task
encoding Portable.Text.Encoding The encoding to use for the user's credentials.
userName string The user name.
password string The password.
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

AuthenticateAsync() public method

Asynchronously authenticates using the specified user name and password.

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then the default login command is used as a fallback.

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.
/// is null. /// -or- /// is null. /// /// The has been disposed. /// /// The is not connected or is already authenticated. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public AuthenticateAsync ( string userName, string password, CancellationToken cancellationToken = default(CancellationToken) ) : Task
userName string The user name.
password string The password.
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

Connect() public method

Establish a connection to the specified mail server.
Establishes a connection to the specified mail server.
/// The is null. /// /// The is not an absolute URI. /// /// The has been disposed. /// /// The is already connected. /// /// The operation was canceled via the cancellation token. /// /// A socket error occurred trying to connect to the remote host. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public Connect ( Uri uri, CancellationToken cancellationToken = default(CancellationToken) ) : void
uri System.Uri The server URI.
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

Connect() public abstract method

Establish a connection to the specified mail server.
Establishes a connection to the specified mail server.
/// is null. /// /// is not between 0 and 65535. /// /// The is a zero-length string. /// /// The has been disposed. /// /// The is already connected. /// /// The operation was canceled via the cancellation token. /// /// A socket error occurred trying to connect to the remote host. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public abstract Connect ( string host, int port, SecureSocketOptions options = SecureSocketOptions.Auto, CancellationToken cancellationToken = default(CancellationToken) ) : void
host string The host name to connect to.
port int The port to connect to. If the specified port is 0, then the default port will be used.
options SecureSocketOptions The secure socket options to when connecting.
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

Connect() public method

Establish a connection to the specified mail server.

Establishes a connection to the specified mail server.

The useSsl argument only controls whether or not the client makes an SSL-wrapped connection. In other words, even if the useSsl parameter is false, SSL/TLS may still be used if the mail server supports the STARTTLS extension.

To disable all use of SSL/TLS, use the Connect(string,int,MailKit.Security.SecureSocketOptions,System.Threading.CancellationToken) overload with a value of SecureSocketOptions.None instead.

/// The is null. /// /// is out of range (0 to 65535, inclusive). /// /// The is a zero-length string. /// /// The has been disposed. /// /// The is already connected. /// /// The operation was canceled via the cancellation token. /// /// A socket error occurred trying to connect to the remote host. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public Connect ( string host, int port, bool useSsl, CancellationToken cancellationToken = default(CancellationToken) ) : void
host string The host to connect to.
port int The port to connect to. If the specified port is 0, then the default port will be used.
useSsl bool true if the client should make an SSL-wrapped connection to the server; otherwise, false.
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

ConnectAsync() public method

Asynchronously establish a connection to the specified mail server.
Asynchronously establishes a connection to the specified mail server.
/// The is null. /// /// The is not an absolute URI. /// /// The has been disposed. /// /// The is already connected. /// /// The operation was canceled via the cancellation token. /// /// A socket error occurred trying to connect to the remote host. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public ConnectAsync ( Uri uri, CancellationToken cancellationToken = default(CancellationToken) ) : Task
uri System.Uri The server URI.
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

ConnectAsync() public method

Asynchronously establish a connection to the specified mail server.
Asynchronously establishes a connection to the specified mail server.
/// is null. /// /// is not between 0 and 65535. /// /// The is a zero-length string. /// /// The has been disposed. /// /// The is already connected. /// /// The operation was canceled via the cancellation token. /// /// A socket error occurred trying to connect to the remote host. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public ConnectAsync ( string host, int port, SecureSocketOptions options = SecureSocketOptions.Auto, CancellationToken cancellationToken = default(CancellationToken) ) : Task
host string The host name to connect to.
port int The port to connect to. If the specified port is 0, then the default port will be used.
options SecureSocketOptions The secure socket options to when connecting.
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

ConnectAsync() public method

Asynchronously establish a connection to the specified mail server.

Asynchronously establishes a connection to the specified mail server.

The useSsl argument only controls whether or not the client makes an SSL-wrapped connection. In other words, even if the useSsl parameter is false, SSL/TLS may still be used if the mail server supports the STARTTLS extension.

To disable all use of SSL/TLS, use the ConnectAsync(string,int,MailKit.Security.SecureSocketOptions,System.Threading.CancellationToken) overload with a value of SecureSocketOptions.None instead.

/// The is null. /// /// is out of range (0 to 65535, inclusive). /// /// The is a zero-length string. /// /// The has been disposed. /// /// The is already connected. /// /// The operation was canceled via the cancellation token. /// /// A socket error occurred trying to connect to the remote host. /// /// An I/O error occurred. /// /// A protocol error occurred. ///
public ConnectAsync ( string host, int port, bool useSsl, CancellationToken cancellationToken = default(CancellationToken) ) : Task
host string The host to connect to.
port int The port to connect to. If the specified port is 0, then the default port will be used.
useSsl bool true if the client should make an SSL-wrapped connection to the server; otherwise, false.
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

DefaultServerCertificateValidationCallback() public static method

The default server certificate validation callback used when connecting via SSL or TLS.

The default server certificate validation callback considers self-signed certificates to be valid so long as the only error in the certificate chain is an untrusted root.

It should be noted that self-signed certificates may be an indication of a man-in-the-middle (MITM) attack and so it is recommended that the client implement a custom server certificate validation callback that presents the certificate to the user in some way, allowing the user to confirm or deny its validity.
public static DefaultServerCertificateValidationCallback ( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors ) : bool
sender object The object that is connecting via SSL or TLS.
certificate System.Security.Cryptography.X509Certificates.X509Certificate The server's SSL certificate.
chain System.Security.Cryptography.X509Certificates.X509Chain The server's SSL certificate chain.
sslPolicyErrors SslPolicyErrors The SSL policy errors.
return bool

Disconnect() public abstract method

Disconnects the service.
If quit is true, a logout/quit command will be issued in order to disconnect cleanly.
/// The has been disposed. ///
public abstract Disconnect ( bool quit, CancellationToken cancellationToken = default(CancellationToken) ) : void
quit bool If set to true, a logout/quit command will be issued in order to disconnect cleanly.
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

DisconnectAsync() public method

Asynchronously disconnects the service.
If quit is true, a logout/quit command will be issued in order to disconnect cleanly.
/// The has been disposed. ///
public DisconnectAsync ( bool quit, CancellationToken cancellationToken = default(CancellationToken) ) : Task
quit bool If set to true, a logout/quit command will be issued in order to disconnect cleanly.
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

Dispose() public method

Releases all resource used by the MailService object.
Call Dispose() when you are finished using the MailService. The Dispose() method leaves the MailService in an unusable state. After calling Dispose(), you must release all references to the MailService so the garbage collector can reclaim the memory that the MailService was occupying.
public Dispose ( ) : void
return void

Dispose() protected method

Releases the unmanaged resources used by the MailService and optionally releases the managed resources.
Releases the unmanaged resources used by the MailService and optionally releases the managed resources.
protected Dispose ( bool disposing ) : void
disposing bool true to release both managed and unmanaged resources; /// false to release only the unmanaged resources.
return void

MailService() protected method

Initializes a new instance of the MailKit.MailService class.
Initializes a new instance of the MailKit.MailService class.
protected MailService ( ) : System
return System

MailService() protected method

Initializes a new instance of the MailKit.MailService class.
Initializes a new instance of the MailKit.MailService class.
/// is null. ///
protected MailService ( IProtocolLogger protocolLogger ) : System
protocolLogger IProtocolLogger The protocol logger.
return System

NoOp() public abstract method

Pings the mail server to keep the connection alive.
Mail servers, if left idle for too long, will automatically drop the connection.
/// The has been disposed. /// /// The is not connected. /// -or- /// The is not authenticated. /// /// The operation was canceled via the cancellation token. /// /// An I/O error occurred. /// /// The command was rejected by the mail server. /// /// The server responded with an unexpected token. ///
public abstract NoOp ( CancellationToken cancellationToken = default(CancellationToken) ) : void
cancellationToken System.Threading.CancellationToken The cancellation token.
return void

NoOpAsync() public method

Asynchronously pings the mail server to keep the connection alive.
Mail servers, if left idle for too long, will automatically drop the connection.
/// The has been disposed. /// /// The is not connected. /// -or- /// The is not authenticated. /// /// The operation was canceled via the cancellation token. /// /// An I/O error occurred. /// /// The command was rejected by the mail server. /// /// The server responded with an unexpected token. ///
public NoOpAsync ( CancellationToken cancellationToken = default(CancellationToken) ) : Task
cancellationToken System.Threading.CancellationToken The cancellation token.
return Task

OnAuthenticated() protected method

Raise the authenticated event.
Raises the authenticated event.
protected OnAuthenticated ( string message ) : void
message string The notification sent by the server when the client successfully authenticates.
return void

OnConnected() protected method

Raise the connected event.
Raises the connected event.
protected OnConnected ( ) : void
return void

OnDisconnected() protected method

Raise the disconnected event.
Raises the disconnected event.
protected OnDisconnected ( ) : void
return void