https://github.com/stefanpoensgen/sptecgmailapimailerbundle
Symfony Mailer Transport for Gmail API including Google OAuth2 authentication.
https://github.com/stefanpoensgen/sptecgmailapimailerbundle
gmail-api google-api hacktoberfest symfony symfony-bundle
Last synced: 4 months ago
JSON representation
Symfony Mailer Transport for Gmail API including Google OAuth2 authentication.
- Host: GitHub
- URL: https://github.com/stefanpoensgen/sptecgmailapimailerbundle
- Owner: stefanpoensgen
- License: mit
- Created: 2022-10-05T19:16:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-23T16:44:58.000Z (over 3 years ago)
- Last Synced: 2024-09-18T04:16:39.317Z (over 1 year ago)
- Topics: gmail-api, google-api, hacktoberfest, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gmail Api Mailer Bundle
Symfony Mailer Transport for Gmail API including Google OAuth2 authentication.
## Requirements
* Symfony >= 5.4
## Installation
#### Step 1: Download the Bundle
Use [Composer](http://getcomposer.org/) to install this bundle:
```
composer require sptec/gmail-api-mailer-bundle
```
#### Step 2: Enable the Bundle
```php
// config/bundles.php
return [
// ...
Sptec\GmailApiMailerBundle\SptecGmailApiMailerBundle => ['all' => true],
];
```
## Configuration
### Google API Client
If you don't use [Symfony Flex](https://github.com/symfony/flex) you have create the following configuration
```yaml
# config/packages/google_apiclient.yaml
services:
Google_Client:
class: Google_Client
calls:
- [setClientId, ['%env(GOOGLE_CLIENT_ID)%']]
- [setClientSecret, ['%env(GOOGLE_CLIENT_SECRET)%']]
```
### .env
```dotenv
###> 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](https://symfony.com/doc/current/configuration/secrets.html).
## Google Credentials
1. Open the [Google Cloud console](https://console.cloud.google.com/).
2. At the top-left, click Menu menu > APIs & Services > Credentials.
3. Click Create Credentials > OAuth client ID.
4. Click Application type > Web application.
5. Enter a name for the OAuth client ID. (e.g. Symfony Gmail API Mailer)
6. Add authorized redirect URIs. (default: http://localhost)
7. Click Create.