PHPackages                             mathsgod/phpmailer-gmail - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mathsgod/phpmailer-gmail

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mathsgod/phpmailer-gmail
========================

1.0.0(1y ago)08MITPHP

Since May 27Pushed 1y agoCompare

[ Source](https://github.com/mathsgod/phpmailer-gmail)[ Packagist](https://packagist.org/packages/mathsgod/phpmailer-gmail)[ RSS](/packages/mathsgod-phpmailer-gmail/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

GmailMailer for PHPMailer
=========================

[](#gmailmailer-for-phpmailer)

This project provides a `GmailMailer` class for sending emails via Gmail SMTP using PHPMailer and OAuth2 authentication.

Features
--------

[](#features)

- Send emails through Gmail SMTP securely
- Uses OAuth2 (no need for less secure app access)
- Simple integration with your PHP projects

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

[](#installation)

1. Clone or download this repository.
2. Install dependencies using Composer:

    ```
    composer install
    ```

Usage
-----

[](#usage)

1. Obtain your Gmail address, Google OAuth2 client ID, client secret, and refresh token.
2. Use the `GmailMailer` class in your PHP script:

    ```
    require 'vendor/autoload.php';
    use PHPMailer\GmailMailer;

    $gmail = 'your-email@gmail.com';
    $clientId = 'YOUR_GOOGLE_CLIENT_ID';
    $clientSecret = 'YOUR_GOOGLE_CLIENT_SECRET';
    $refreshToken = 'YOUR_REFRESH_TOKEN';

    $mailer = new GmailMailer(true, $gmail, $clientId, $clientSecret, $refreshToken);
    $mailer->addAddress('recipient@example.com');
    $mailer->Subject = 'Test Email';
    $mailer->Body = 'This is a test email sent via Gmail SMTP with OAuth2.';

    if ($mailer->send()) {
        echo "Message sent!";
    } else {
        echo "Mailer Error: " . $mailer->ErrorInfo;
    }
    ```

How to Get OAuth2 Credentials
-----------------------------

[](#how-to-get-oauth2-credentials)

For detailed instructions on obtaining OAuth2 credentials and generating a refresh token, please refer to the [thephpleague/oauth2-google GitHub repository](https://github.com/thephpleague/oauth2-google).

License
-------

[](#license)

MIT License.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance46

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

403d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18732337?v=4)[Raymond](/maintainers/mathsgod)[@mathsgod](https://github.com/mathsgod)

---

Top Contributors

[![mathsgod](https://avatars.githubusercontent.com/u/18732337?v=4)](https://github.com/mathsgod "mathsgod (5 commits)")

### Embed Badge

![Health badge](/badges/mathsgod-phpmailer-gmail/health.svg)

```
[![Health](https://phpackages.com/badges/mathsgod-phpmailer-gmail/health.svg)](https://phpackages.com/packages/mathsgod-phpmailer-gmail)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[chameleon-system/chameleon-base

The Chameleon System core.

1028.6k5](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

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