├── CHANGELOG.md ├── LICENSE ├── README.md ├── Transport ├── GmailSmtpTransport.php └── GmailTransportFactory.php └── composer.json /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | 4.4.0 5 | ----- 6 | 7 | * [BC BREAK] Renamed and moved `Symfony\Component\Mailer\Bridge\Google\Smtp\GmailTransport` 8 | to `Symfony\Component\Mailer\Bridge\Google\Transport\GmailSmtpTransport`. 9 | 10 | 4.3.0 11 | ----- 12 | 13 | * Added the bridge 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019-present Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Google Mailer 2 | ============= 3 | 4 | Provides Google Gmail integration for Symfony Mailer. 5 | 6 | Configuration example: 7 | 8 | ```env 9 | # SMTP 10 | MAILER_DSN=gmail+smtp://USERNAME:APP-PASSWORD@default 11 | ``` 12 | 13 | Resources 14 | --------- 15 | 16 | * [Contributing](https://symfony.com/doc/current/contributing/index.html) 17 | * [Report issues](https://github.com/symfony/symfony/issues) and 18 | [send Pull Requests](https://github.com/symfony/symfony/pulls) 19 | in the [main Symfony repository](https://github.com/symfony/symfony) 20 | -------------------------------------------------------------------------------- /Transport/GmailSmtpTransport.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Component\Mailer\Bridge\Google\Transport; 13 | 14 | use Psr\EventDispatcher\EventDispatcherInterface; 15 | use Psr\Log\LoggerInterface; 16 | use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; 17 | 18 | /** 19 | * @author Kevin Verschaeve 20 | */ 21 | class GmailSmtpTransport extends EsmtpTransport 22 | { 23 | public function __construct(string $username, #[\SensitiveParameter] string $password, ?EventDispatcherInterface $dispatcher = null, ?LoggerInterface $logger = null) 24 | { 25 | parent::__construct('smtp.gmail.com', 465, true, $dispatcher, $logger); 26 | 27 | $this->setUsername($username); 28 | $this->setPassword($password); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Transport/GmailTransportFactory.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Component\Mailer\Bridge\Google\Transport; 13 | 14 | use Symfony\Component\Mailer\Exception\UnsupportedSchemeException; 15 | use Symfony\Component\Mailer\Transport\AbstractTransportFactory; 16 | use Symfony\Component\Mailer\Transport\Dsn; 17 | use Symfony\Component\Mailer\Transport\TransportInterface; 18 | 19 | /** 20 | * @author Konstantin Myakshin 21 | */ 22 | final class GmailTransportFactory extends AbstractTransportFactory 23 | { 24 | public function create(Dsn $dsn): TransportInterface 25 | { 26 | if (\in_array($dsn->getScheme(), $this->getSupportedSchemes(), true)) { 27 | return new GmailSmtpTransport($this->getUser($dsn), $this->getPassword($dsn), $this->dispatcher, $this->logger); 28 | } 29 | 30 | throw new UnsupportedSchemeException($dsn, 'gmail', $this->getSupportedSchemes()); 31 | } 32 | 33 | protected function getSupportedSchemes(): array 34 | { 35 | return ['gmail', 'gmail+smtp', 'gmail+smtps']; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "symfony/google-mailer", 3 | "type": "symfony-mailer-bridge", 4 | "description": "Symfony Google Mailer Bridge", 5 | "keywords": [], 6 | "homepage": "https://symfony.com", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Fabien Potencier", 11 | "email": "fabien@symfony.com" 12 | }, 13 | { 14 | "name": "Symfony Community", 15 | "homepage": "https://symfony.com/contributors" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=8.2", 20 | "symfony/mailer": "^7.2" 21 | }, 22 | "require-dev": { 23 | "symfony/http-client": "^6.4|^7.0" 24 | }, 25 | "autoload": { 26 | "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Google\\": "" }, 27 | "exclude-from-classmap": [ 28 | "/Tests/" 29 | ] 30 | }, 31 | "minimum-stability": "dev" 32 | } 33 | --------------------------------------------------------------------------------