The default authentication method is smtpAuthLogin
and this is accepted by most mail servers. If you attempt to use an
authentication method which is not supported by the server, the
Authenticate method will fail and the last error
code will be set to stErrorInvalidAuthenticationType.
All authentication methods require the mail server to support the
standard service extensions for authentication as specified in the RFC
4954. The server must support the ESMTP protocol extensions and the
AUTH command. A user name and password are required for
authentication. If you wish to authenticate without a user password,
you must use one of the OAuth 2.0 authentication methods.
You should only use an OAuth 2.0 authentication method if
you understand the process of how to request the access token. Obtaining
an access token requires registering your application with the mail
service provider (e.g.: Microsoft or Google), getting a unique
client ID associated with your application and then requesting the
access token using the appropriate scope for the service. Obtaining
the initial token will typically involve interactive confirmation
on the part of the user, requiring they grant permission to your
application to access their mail account.
The smtpAuthXOAuth2 and smtpAuthBearer
authentication methods are similar, but they are not interchangeable.
Both use an OAuth 2.0 bearer token to authenticate the client session,
but they differ in how the token is presented to the server. It is
currently preferable to use the XOAUTH2 method because it is more
widely available and some service providers do not yet support the
OAUTHBEARER method.
Changing the value of the BearerToken property will
automatically set the current authentication method to use OAuth 2.0.