Migrate Microsoft 365 Email Module from Basic Auth to OAuth2

As Basic Auth is not recommended and is expired Microsoft to use. I’m wanted to force SuiteCRM to use OAuth2 to connect MS365 by either create a new helper or configure on SuiteCRM Email Settings. I’ve followed the steps from How to configure a Microsoft OAuth Provider :: SuiteCRM Documentation , but reaching many blockers that is not able to connect successfully such as API Permission with MS365 and Access Denied errors, steps and configuration from MS365 are correct.

Anyone else able to use MS365 service without Basic Auth?

You will find some topics in this forum related to it.

  1. Email import failure on new install

  2. SuiteCRM8 inbound email account OAuth fails

Just today, I’ve managed to get it work by creating a new custom version of SugarPHPMailer.php to overwrite the core SugarPHPMailer.php and a custom GraphEmailService.php helper. This way will be able to force CRM to use Microsoft Graph API to call sending emails. All working as expected, one problem is to make sure the accessibility with MS passed with adding Application Permission Mail.Send (If you’re hitting ErrorAccessDenied error code)

Could you please share your code changes here?