Imap ClientAuthenticate(Encoding, ICredentials, Cancellation Token) Method
Authenticate using the supplied credentials.
Definition
Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
IMailServiceAuthenticate(Encoding, ICredentials, CancellationToken)
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
public override void Authenticate(
Encoding encoding,
ICredentials credentials,
CancellationToken cancellationToken = default
)Parameters
- encoding Encoding
- The text encoding to use for the user's credentials.
- credentials ICredentials
- The user's credentials.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
Implements
IMailServiceAuthenticate(Encoding, ICredentials, CancellationToken)IMailServiceAuthenticate(Encoding, ICredentials, CancellationToken)
Remarks
Authenticates using the supplied credentials.
If the IMAP server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support (not including any OAUTH mechanisms) 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 LOGIN command is used as a fallback.
Exceptions
| ArgumentNullException |
encoding is . -or- credentials is . |
| ObjectDisposedException | The ImapClient has been disposed. |
| ServiceNotConnectedException | The ImapClient is not connected. |
| InvalidOperationException | The ImapClient is already authenticated. |
| OperationCanceledException | The operation was canceled via the cancellation token. |
| AuthenticationException | Authentication using the supplied credentials has failed. |
| SaslException | A SASL authentication error occurred. |
| IOException | An I/O error occurred. |
| ImapCommandException | An IMAP command failed. |
| ImapProtocolException | An IMAP protocol error occurred. |