AuthType Property  
 

Gets and sets the method used to authenticate the user.

Syntax

object.AuthType [= type ]

Remarks

The AuthType property specifies the type of authentication that should be used when the client connects to the mail server. The following authentication methods are supported:

Value Constant Description
0 smtpAuthLogin The client will authenticate using the AUTH LOGIN command. This encodes the username and password, however the credentials are not encrypted and it is recommended you use a secure connection. This is the default method accepted by most mail servers and is the preferred authentication type for most clients.
1 smtpAuthPlain The client will authenticate using the AUTH PLAIN command. This encodes the username and password, however the credentials are not encrypted and it is recommended you use a secure connection. The server must support the PLAIN Simple Authentication and Security Layer (SASL) mechanism as defined in RFC 4616.
3 smtpAuthXOAuth2 The client will authenticate using the AUTH XOAUTH2 command. This authentication method does not require the user password, instead the BearerToken property must specify the OAuth 2.0 bearer token issued by the service provider. The application must provide a valid access token which has not expired or the user authentication will fail.
4 smtpAuthBearer The client will authenticate using the AUTH OAUTHBEARER command as defined in RFC 7628. This authentication method does not require the user password, instead the BearerToken property must specify the OAuth 2.0 bearer token issued by the service provider. The application must provide a valid access token which has not expired or the user authentication will fail.

Data Type

Integer (Int32)

Remarks

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.

See Also

BearerToken Property, Password Property, UserName Property, Authenticate Method, Connect Method