Click or drag to resize
MimeKit

IMailServiceAuthenticateAsync(ICredentials, CancellationToken) Method

Asynchronously authenticate using the supplied credentials.

Namespace: MailKit
Assembly: MailKit (in MailKit.dll) Version: 4.7.1
Syntax
C#
Task AuthenticateAsync(
	ICredentials credentials,
	CancellationToken cancellationToken = default
)

Parameters

credentials  ICredentials
The user's credentials.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An asynchronous task context.
Exceptions
ExceptionCondition
ArgumentNullExceptioncredentials is null.
ObjectDisposedException The IMailService has been disposed.
ServiceNotConnectedException The IMailService is not connected.
InvalidOperationException The IMailService 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.
ProtocolException A protocol error occurred.
Remarks

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 (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 the default login command is used as a fallback.

See Also