pioneeringtechlab/laravel-gmail-oauth-mailer

Gmail OAuth2 SMTP mail transport for Laravel 10, 11, and 12 using Symfony Mailer.

Maintainers

Package info

github.com/PioneeringTechLab/laravel-gmail-oauth-mailer

pkg:composer/pioneeringtechlab/laravel-gmail-oauth-mailer

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-07-02 05:00 UTC

This package is auto-updated.

Last update: 2026-07-02 21:18:53 UTC


README

Gmail OAuth2 SMTP XOAUTH2 mail transport for Laravel 10, 11, and 12 using Symfony Mailer.

Installation

Run the following command on your Laravel project root directory:

composer require pioneeringtechlab/laravel-gmail-oauth-mailer:^1.0

Publish config

php artisan vendor:publish --tag=gmail-oauth-mailer-config

Configure Laravel mailer

In config/mail.php, add a mailer:

'mailers' => [
    // ...

    'gmail-oauth' => [
        'transport' => 'gmail-oauth',
    ],
],

Environment variables

MAIL_MAILER=gmail-oauth
MAIL_FROM_ADDRESS=youraddress@gmail.com
MAIL_FROM_NAME="${APP_NAME}"

GMAIL_OAUTH_EMAIL=youraddress@gmail.com
GMAIL_OAUTH_CLIENT_ID=your-google-client-id
GMAIL_OAUTH_CLIENT_SECRET=your-google-client-secret
GMAIL_OAUTH_REFRESH_TOKEN=your-refresh-token

GMAIL_OAUTH_SCOPE=https://mail.google.com/
GMAIL_OAUTH_HOST=smtp.gmail.com
GMAIL_OAUTH_PORT=587
GMAIL_OAUTH_ENCRYPTION=tls

After editing env/config values:

php artisan config:clear

Notes

  • For Gmail SMTP OAuth2, the usual scope is https://mail.google.com/.
  • Port 587 normally uses GMAIL_OAUTH_ENCRYPTION=tls.
  • Port 465 normally uses GMAIL_OAUTH_ENCRYPTION=ssl.
  • This package refreshes the access token when Laravel creates the mail transport. It does not cache the access token.