ad5jp/laravel-gmail

Laravel Mail Driver for Gmail API via Service Account
12,873 7
Install
composer require ad5jp/laravel-gmail
Latest Version:v4.0.5
PHP:^7.2|^8.0
Laravel:9 – 13
License:MIT
Last Updated:Oct 1, 2026
Links: GitHub  ·  Packagist
Maintainer: ad5jp

Laravel Mailer for Gmail API

This package allows you to use the Gmail API as a mailer in Laravel. You can send emails from Laravel via the Gmail API without modifying your existing code.

Instead of using OAuth, this package uses a service account for sending emails. This eliminates the need for user authentication processes and access token management, while ensuring the method does not fall under LSA (Less Secure Apps).

日本語はこちら

Installation

composer require ad5jp/laravel-gmail  

Specify the version according to your environment:

  • v4.x ... Laravel 9 and later
  • v3.x ... Laravel 7 - 8
  • v2.x ... Laravel 6 and earlier
  • v1.x ... Laravel 6 and earlier with google/apiclient-service before v0.200.0

Usage

1. Create a Service Account on Google Cloud Platform

  1. Create a project in the Google Cloud Platform console.
  2. Enable the Gmail API.
  3. Create a service account, generate a key, and download it in JSON format.
  4. In the Google Workspace admin console, set up "Domain-wide Delegation". Assign the scope https://www.googleapis.com/auth/gmail.send to the service account created above.

2. Place the Key

Place the JSON key downloaded in step 2 within your application. Ensure it is excluded from source control using .gitignore or similar.

3. Configure .env

Change the value of MAIL_MAILER in your .env file to gmail. (Or change the 'default' value in config/mail.php)

For Laravel 6 and earlier, change the value of MAIL_DRIVER in your .env file to gmail. (Or change the 'driver' value in config/mail.php)

Add the following lines to your .env file:

GMAIL_FROM_ADDRESS={Sender's email address}  
GMAIL_SERVICE_ACCOUNT_KEY={Path to the JSON key placed in step 2}  

The sender's email address must be an email address within the Google Workspace organization set up in step 1 (4).

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

502,645,077 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

418,291,778 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
v4.0.5 ^7.2|^8.0 ^9.0|^10.0|^11.0|^12.0|^13.0 MIT
v4.0.4 ^7.2|^8.0 ^9.0|^10.0|^11.0|^12.0 MIT
v4.0.3 ^7.2|^8.0 ^9.0|^10.0|^11.0 MIT
v4.0.2 ^7.2|^8.0 ^9.0|^10.0|^11.0 MIT
v4.0.1 ^7.2|^8.0 ^9.0|^10.0|^11.0 MIT