PHPackages                             mwagena/gmail-api-wrapper - 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. [API Development](/categories/api)
4. /
5. mwagena/gmail-api-wrapper

ActiveLibrary[API Development](/categories/api)

mwagena/gmail-api-wrapper
=========================

Laravel 5 wrapper for Gmail API

65163[1 issues](https://github.com/mwagena/Gmail-Api-wrapper/issues)PHP

Since May 16Pushed 9y ago1 watchersCompare

[ Source](https://github.com/mwagena/Gmail-Api-wrapper)[ Packagist](https://packagist.org/packages/mwagena/gmail-api-wrapper)[ RSS](/packages/mwagena-gmail-api-wrapper/feed)WikiDiscussions develop Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Gmail API wrapper for Laravel 5.x
=================================

[](#gmail-api-wrapper-for-laravel-5x)

Setup the api:

Step 1: Turn on the Gmail API
-----------------------------

[](#step-1-turn-on-the-gmail-api)

- Use [this](https://console.developers.google.com/flows/enableapi?apiid=gmail&pli=1) wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click**Continue**, then**Go to credentials**.
- On the**Add credentials**to your project page, click the**Cancel**button.
- At the top of the page, select the**OAuth consent screen**tab. Select an**Email address**, enter a**Product name**if not already set, and click the**Save**button.
- Select the**Credentials**tab, click the**Create credentials**button and select**OAuth client ID**.
- Select the application type **webapp**, enter the name of your choosings, fill out the redirect uri to your project and click the**Create button**.
- You will now receive a **Client-ID** and **Client secret**, copy and paste the settings somewere save since you will be needing these later.

Step 2: Sign in with the Client-ID and secret
---------------------------------------------

[](#step-2-sign-in-with-the-client-id-and-secret)

Initiate the Gmail class

```
$gmail = new Gmail();

```

```
$gmail->getAuthUrl();

```

Use the returned code from the previous call to create a access + refresh token

```
$gmail->makeAccessToken($code);

```

Step 3: make use of it all
--------------------------

[](#step-3-make-use-of-it-all)

Initiate connection

```
$gmail = MartijnWagena\Gmail\Mail::create()
            ->setAccessToken($access_token, $refresh_token)
            ->setStartDate($date);

```

Check if token refresh needed

```
$gmail->isAccessTokenExpired();

```

Fetch all messages starting from the 'setStartDate', you only receive the ids of the messages

```
$gmail->fetch();

```

To fetch details of a message, use the code below

```
$gmail->getMessage($id, $threadId);

```

Send mails with the api

```
$gmail = MartijnWagena\Gmail\Send::create()->setAccessToken($access_token, $refresh_token);

$gmail->sendMail(
    [['email' => 'name@mail.com']],
    [['email' => 'name2@mail.com']],
    [['email' => 'name3@mail.com']],
    'your subject',
    'your message body',
    'inreplytomessageId',
    [] // array of attachments of type File
);

```

Step 5: If wanted, revoke access
--------------------------------

[](#step-5-if-wanted-revoke-access)

```
$gmail = MartijnWagena\Gmail::create()->setAccessToken($access_token, $refresh_token);
$gmail->revokeAccess();

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/be025f7ad73d6ab140663f399b03c5eb6b60785d7040b4eb5ea2c7c3d5b629b5?d=identicon)[niltonmelox](/maintainers/niltonmelox)

### Embed Badge

![Health badge](/badges/mwagena-gmail-api-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/mwagena-gmail-api-wrapper/health.svg)](https://phpackages.com/packages/mwagena-gmail-api-wrapper)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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