PHPackages                             iagofelicio/laravel-gmail-oauth2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. iagofelicio/laravel-gmail-oauth2

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

iagofelicio/laravel-gmail-oauth2
================================

Send emails with Gmail OAuth2 credentials instead of SMTP default access information

2.0.5(2y ago)74.0k↓31.8%MITPHPPHP &gt;=8.0

Since Apr 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Iagofelicio/laravel-gmail-oauth2)[ Packagist](https://packagist.org/packages/iagofelicio/laravel-gmail-oauth2)[ RSS](/packages/iagofelicio-laravel-gmail-oauth2/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (13)Used By (0)

Send emails with Gmail OAuth2 credentials
=========================================

[](#send-emails-with-gmail-oauth2-credentials)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8cc8642a254d2b9d3a1ab5bc85ec69e9a0f1c20cdcdafa5c882e626ff8c7b680/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6961676f66656c6963696f2f6c61726176656c2d676d61696c2d6f61757468322e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iagofelicio/laravel-gmail-oauth2)[![Total Downloads](https://camo.githubusercontent.com/181fa2ec81675cf1c45a91b9ec9111e038f8f048f36a542648922783f6fd3f9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6961676f66656c6963696f2f6c61726176656c2d676d61696c2d6f61757468322e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iagofelicio/laravel-gmail-oauth2)

This Laravel package allows you to send emails securely using Gmail OAuth2 credentials, eliminating the need to store sensitive information like username and password in your application configuration.

Support us
----------

[](#support-us)

This package is actively maintained and free to use. If you find it helpful, consider giving back by:

- Reporting any issues or suggesting improvements through GitHub issues.
- Contributing code or documentation changes via pull requests.
- Leaving a star on the repository to show your appreciation. Your support helps keep this project alive and thriving!
- Supporting me on Ko-fi

[![ko-fi](https://camo.githubusercontent.com/201ef269611db7eb6b5d08e9f756ab8980df3014b64492770bdf13a6ed924641/68747470733a2f2f6b6f2d66692e636f6d2f696d672f676974687562627574746f6e5f736d2e737667)](https://ko-fi.com/E1E3C4XVI)

Installation
------------

[](#installation)

You can install the package via composer:

For PHP 8 and Laravel 9:

```
composer require iagofelicio/laravel-gmail-oauth2
```

For PHP 7 and Laravel 7/8:

```
composer require iagofelicio/laravel-gmail-oauth2:1.0.4
```

Gmail Credentials
-----------------

[](#gmail-credentials)

To obtain a Gmail OAuth2 refresh token, you can refer to the instructions provided by the PHPMailer package on Github .

For detailed instructions on generating a Gmail OAuth2 refresh token, we recommend following the excellent tutorial provided by Coding Yet .

This tutorial walks you through the process step-by-step, ensuring a smooth setup for your secure email sending.

Usage
-----

[](#usage)

### (Step 1) For PHP 7 and Laravel 7/8:

[](#step-1-for-php-7-and-laravel-78)

Edit `config/mail.php` adding the following line:

```
return [

    'driver' => 'gmail',

    // Default code ...
];
```

### (Step 1) For PHP 8 and Laravel 9:

[](#step-1-for-php-8-and-laravel-9)

Edit `config/mail.php` adding the following mailer:

```
return [

    'mailers' => [

        // Default code ...

        'gmail' => [
            'transport' => 'gmail',
        ],
    ]
];
```

Edit the MAIL\_MAILER in `.env` file:

```
MAIL_MAILER=gmail
```

### (Step 2) For Laravel 7, 8 and 9:

[](#step-2-for-laravel-7-8-and-9)

Add your Gmail credentials in `.env` file:

```
GMAIL_API_CLIENT_ID="your-api-client-id"
GMAIL_API_CLIENT_SECRET="your-api-client-secret"
GMAIL_API_CLIENT_REFRESH_TOKEN="your-api-client-refresh-token"
GMAIL_API_CLIENT_MAIL="your-api-client-email"

# Suggested default settings to include
MAIL_FROM_ADDRESS="from@mail.com"
MAIL_FROM_NAME="${APP_NAME}"
```

Testing
-------

[](#testing)

Pending development.

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Iago Felicio](https://github.com/iagofelicio)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

12

Last Release

763d ago

Major Versions

1.0.1 → 2.0.02024-04-15

1.0.4 → 2.0.52024-04-15

PHP version history (2 changes)1.0.0PHP ^7.0

2.0.1PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6cb68439bfe95b9a052f2f607b0553247cfe46356c19614e904492035331ca58?d=identicon)[Iagofelicio](/maintainers/Iagofelicio)

---

Top Contributors

[![Iagofelicio](https://avatars.githubusercontent.com/u/993139?v=4)](https://github.com/Iagofelicio "Iagofelicio (34 commits)")

---

Tags

pending

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/iagofelicio-laravel-gmail-oauth2/health.svg)

```
[![Health](https://phpackages.com/badges/iagofelicio-laravel-gmail-oauth2/health.svg)](https://phpackages.com/packages/iagofelicio-laravel-gmail-oauth2)
```

###  Alternatives

[mckenziearts/laravel-notify

Flexible flash notifications for Laravel

1.7k1.1M5](/packages/mckenziearts-laravel-notify)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[illuminate/mail

The Illuminate Mail package.

5910.1M391](/packages/illuminate-mail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
