Click or drag to resize
MimeKit

Pop3ClientAuthenticate(Encoding, ICredentials, CancellationToken) Method

Authenticate using the supplied credentials.

Namespace: MailKit.Net.Pop3
Assembly: MailKit (in MailKit.dll) Version: 4.3.0
Syntax
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)
Exceptions
ExceptionCondition
ArgumentNullException

encoding is null.

-or-

credentials is null.

ObjectDisposedException The Pop3Client has been disposed.
ServiceNotConnectedException The Pop3Client is not connected.
InvalidOperationException The Pop3Client 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.
Pop3CommandException A POP3 command failed.
Pop3ProtocolException An POP3 protocol error occurred.
Remarks

Authenticates using the supplied credentials.

If the POP3 server supports the APOP authentication mechanism, then APOP is used.

If the APOP authentication mechanism is not supported and 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 USER and PASS commands are used as a fallback.

Tip  Tip

To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.

In the case of the APOP authentication mechanism, remove it from the Capabilities property instead.

See Also