Code Monkey home page Code Monkey logo

laravel-gmail-oauth2's Introduction

Send emails with Gmail OAuth2 credentials

Latest Version on Packagist Total Downloads

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

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

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

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

For detailed instructions on generating a Gmail OAuth2 refresh token, we recommend following the excellent tutorial provided by Coding Yet https://www.codingyet.com/how-to-use-phpmailer-with-xoauth2/.

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

Usage

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

Edit config/mail.php adding the following line:

return [

    'driver' => 'gmail',
    
    // Default code ...
];

(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:

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="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

Testing

Pending development.

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

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

laravel-gmail-oauth2's People

Contributors

iagofelicio avatar

Stargazers

Salim Kanoun avatar Chun-Sheng, Li avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.