The POP_AUTH_LOGIN and POP_AUTH_PLAIN authentication methods
require the mail server support the Simple Authentication and Security
Layer (SASL) AUTH command as defined in RFC 5034. Most modern mail
servers do support one or both of these methods, and they are
generally preferred over the POP_AUTH_PASS method when
possible. However, for backwards compatibility with legacy servers,
the class will default to using POP_AUTH_PASS for client
authentication.
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 POP_AUTH_XOAUTH2 and POP_AUTH_BEARER 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.
Your application should not store an OAuth 2.0 bearer token for later
use. They have a relatively short lifespan, typically about an hour, and
are designed to be used with that session. You should specify offline
access as part of the OAuth 2.0 scope if necessary and store the refresh
token provided by the service. The refresh token has a much longer
validity period and can be used to obtain a new bearer token when needed.