public Task AuthenticateAsync( string userName, string password, CancellationToken cancellationToken = default )
userName is null.
password is null.
|The MailService has been disposed.
|The MailService 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.
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.
|To prevent the usage of certain authentication mechanisms, simply remove them from the AuthenticationMechanisms hash set before calling this method.