Sending Emails with Gmail in CakePHP Now That OAuth is Required

Google has announced that starting September 30, 2024, it will require OAuth for sending emails via Gmail, as stated in this support article.

I’m currently using CakePHP 5 and the built-in Cake\Mailer\Mailer class to send emails via Gmail’s SMTP server. With this new requirement, how should I configure CakePHP to authenticate via OAuth instead of using the traditional username/password approach?

  • Are there any existing plugins or libraries that integrate Gmail’s OAuth authentication with CakePHP’s Mailer?
  • What would be the recommended approach for obtaining and refreshing the access tokens within a CakePHP application?
  • Is there an example of a working implementation for sending emails using OAuth in CakePHP?

Any guidance or example code would be greatly appreciated!

I got it working as a plugin GitHub - toggenation/gmail-email-send: Send email via Gmail API with XOAUTH2 Authentication but it’s been months since I looked at it