This is a simple example and could probably use some refactoring.

It provides basic OAuth2 support for the PHPMailer SMTP module versions >= 2.1.x.

Currently only supports Azure authentication. Because Microsoft does not support client credentials flow for SMTP (yet), occasional manual updates of the auth and refresh token are required.

Configuration is at: Config -> System -> PHPMailer OAuth2

Once enabled, set the Authentication Type within PHPMailer SMTP.