sptec / gmail-api-mailer-bundle
Symfony Mailer Transport for Gmail API including Google OAuth2 authentication.
Installs: 179
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.4
- google/apiclient: ^2.0
- symfony/config: ^5.4|^6.0
- symfony/dependency-injection: ^5.4|^6.0
- symfony/mailer: ^5.4|^6.0
Requires (Dev)
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.8
- phpstan/phpstan-symfony: ^1.2
- phpunit/phpunit: ^9.5
- symfony/http-client: ^5.4|^6.0
- symfony/phpunit-bridge: ^5.4|^6.0
- symplify/easy-coding-standard: ^11.1
This package is auto-updated.
Last update: 2025-04-23 22:25:45 UTC
README
Symfony Mailer Transport for Gmail API including Google OAuth2 authentication.
Requirements
- Symfony >= 5.4
Installation
Step 1: Download the Bundle
Use Composer to install this bundle:
composer require sptec/gmail-api-mailer-bundle
Step 2: Enable the Bundle
// config/bundles.php return [ // ... Sptec\GmailApiMailerBundle\SptecGmailApiMailerBundle => ['all' => true], ];
Configuration
Google API Client
If you don't use Symfony Flex you have create the following configuration
# config/packages/google_apiclient.yaml services: Google_Client: class: Google_Client calls: - [setClientId, ['%env(GOOGLE_CLIENT_ID)%']] - [setClientSecret, ['%env(GOOGLE_CLIENT_SECRET)%']]
.env
###> google/apiclient ### GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= ###< google/apiclient ### ###> symfony/mailer ### MAILER_DSN=gmail+api://null ###< symfony/mailer ###
Usage
bin/console sptec:google:auth
Your Google access token will be stored as json environment variable GOOGLE_ACCESS_TOKEN
by using Symfony's secrets management system.
Google Credentials
- Open the Google Cloud console.
- At the top-left, click Menu menu > APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Click Application type > Web application.
- Enter a name for the OAuth client ID. (e.g. Symfony Gmail API Mailer)
- Add authorized redirect URIs. (default: http://localhost)
- Click Create.