dev/core#2141 - Allow OAuth2 services to define mail setup routine
Overview
--------
For certain types of mail accounts -- such as Google Mail and Microsoft
Exchange Online -- the setup process may require interaction with a remote
web-service.
If you have OAuth2 enabled for one of these services, then this will create
an option for "Add Mail Account".
Before
------
There is no setup procedure.
After
-----
* Navigate to "Administer => CiviMail => Mail Accounts".
* Below the table, there is a select2 box for "Add Mail Account".
* If "Microsoft Exchange Online" is configured, then it will appear in the dropdown. Choose it.
* It redirects to MS to get authorization from the user (OAuth2 Authorization Code).
* The user comes back.
* We initialize a new mail account (`MailSettings` / `civicrm_mail_settings`)
* We accept the code and save the token (`OAuthSysToken`) with the account.
* We redirect to the account configuration form.
Technical Details
-----------------
The new mail account will have some details, such as `server`, `protocol`,
and `username` pre-filled. This uses a template -- see e.g.
`providers/ms-exchange.dist.json` (`mailSettingsTemplate`).