diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..00d6655 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,34 @@ +version: 2 # use CircleCI 2.0 + +jobs: # a collection of steps + build: # runs not using Workflows must have a `build` job as entry point + working_directory: ~/sendinblue-mailer # directory where steps will run + docker: # run the steps with Docker + - image: circleci/php:fpm-stretch # ...with this image as the primary container; this is where all `steps` will run environment: + environment: + APP_ENV: test + steps: + - run: + name: Install system packages + command: sudo apt-get update && sudo apt-get -y install git + - checkout + - run: + name: Install Composer + command: | + php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" + php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('https://composer.github.io/installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer invalid'; unlink('composer-setup.php'); } echo PHP_EOL;" + php composer-setup.php + php -r "unlink('composer-setup.php');" + - run: + name: Display PHP information + command: | + php -v + php composer.phar --version + - run: + name: Install project dependencies + command: php composer.phar install + - run: + name: Run tests + command: ./vendor/bin/simple-phpunit --coverage-html build/coverage-report + - store_artifacts: + path: build/coverage-report \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cfea7ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build +vendor +.phpunit.* +composer.lock diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..cf04bff --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +CHANGELOG +========= + +1.0.0 +----- + + * Added the bridge diff --git a/DependencyInjection/SendinblueMailerExtension.php b/DependencyInjection/SendinblueMailerExtension.php new file mode 100644 index 0000000..dc2f7df --- /dev/null +++ b/DependencyInjection/SendinblueMailerExtension.php @@ -0,0 +1,25 @@ +load('mailer_transport.xml'); + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b9fe484 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Yann LUCAS + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3071a9e --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +Sendinblue Mailer +================= + +Provides Sendinblue integration for Symfony Mailer. + +[![CircleCI](https://circleci.com/gh/drixs6o9/sendinblue-mailer/tree/master.svg?style=svg)](https://circleci.com/gh/drixs6o9/sendinblue-mailer/tree/master) + +Installation +------------ + +Open a command console inyour project directory and execute the +following command to download the latest stable version of this bundle: + +```bash +$ composer require drixs6o9/sendinblue-mailer +``` + +Then, enable the bundle by adding the following line in the `config/bundle.php` +file of your project: + +```php + ['all' => true], +]; +``` + +Finally, add your Sendinblue credentials into your `.env.local` file of your project: +```env +###> drixs6o9/sendinblue-mailer ### +SENDINBLUE_USERNAME=username +SENDINBLUE_PASSWORD=password +MAILER_DSN=smtp://$SENDINBLUE_USERNAME:$SENDINBLUE_PASSWORD@sendinblue +###< drixs6o9/sendinblue-mailer ### +``` + +Resources +--------- + + * [Report issues](https://github.com/drixs6o9/sendinblue-mailer/issues) + * [Send Pull Requests](https://github.com/drixs6o9/sendinblue-mailer/pulls) diff --git a/Resources/mailer_transport.xml b/Resources/mailer_transport.xml new file mode 100644 index 0000000..44f0810 --- /dev/null +++ b/Resources/mailer_transport.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/SendinblueMailerBundle.php b/SendinblueMailerBundle.php new file mode 100644 index 0000000..0795ddf --- /dev/null +++ b/SendinblueMailerBundle.php @@ -0,0 +1,14 @@ +getDispatcher(), $this->getClient(), $this->getLogger()); + } + + /** + * {@inheritDoc} + */ + public function supportsProvider(): iterable + { + yield [ + new Dsn('smtp', 'sendinblue'), + true, + ]; + + yield [ + new Dsn('smtp', 'example.com'), + false, + ]; + } + + /** + * {@inheritDoc} + */ + public function createProvider(): iterable + { + yield [ + new Dsn('smtp', 'sendinblue', self::USER, self::PASSWORD), + new SendinblueSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()), + ]; + } + + /** + * {@inheritDoc} + */ + public function unsupportedSchemeProvider(): iterable + { + yield [ + new Dsn('foo', 'sendinblue', self::USER, self::PASSWORD), + 'The "foo" scheme is not supported for mailer "sendinblue". Supported schemes are: "smtp".', + ]; + } + + /** + * {@inheritDoc} + */ + public function incompleteDsnProvider(): iterable + { + yield [new Dsn('smtp', 'sendinblue', self::USER)]; + } +} diff --git a/Transport/SendinblueSmtpTransport.php b/Transport/SendinblueSmtpTransport.php new file mode 100644 index 0000000..fa2da65 --- /dev/null +++ b/Transport/SendinblueSmtpTransport.php @@ -0,0 +1,41 @@ +setUsername($username); + $this->setPassword($password); + } +} diff --git a/Transport/SendinblueTransportFactory.php b/Transport/SendinblueTransportFactory.php new file mode 100644 index 0000000..7cd38f5 --- /dev/null +++ b/Transport/SendinblueTransportFactory.php @@ -0,0 +1,41 @@ +getScheme()) { + throw new UnsupportedSchemeException($dsn, ['smtp']); + } + + return new SendinblueSmtpTransport( + $this->getUser($dsn), + $this->getPassword($dsn), + $this->dispatcher, + $this->logger + ); + } + + /** + * {@inheritDoc} + */ + public function supports(Dsn $dsn): bool + { + return 'sendinblue' === $dsn->getHost(); + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..5322d33 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "drixs6o9/sendinblue-mailer", + "type": "symfony-bridge", + "description": "Symfony Sendinblue Mailer Bridge", + "keywords": ["symfony", "sendinblue", "mailer", "bridge"], + "homepage": "https://github.com/drixs6o9", + "license": "MIT", + "authors": [ + { + "name": "Yann LUCAS", + "email": "yann.lucas@oulook.com" + } + ], + "require": { + "php": "^7.2.9", + "symfony/mailer": "^4.4|^5.0" + }, + "require-dev": { + "symfony/http-client": "^4.4|^5.0", + "symfony/test-pack": "*" + }, + "autoload": { + "psr-4": { "Drixs6o9\\SendinblueMailerBundle\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "minimum-stability": "dev" +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..4bd286e --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,32 @@ + + + + + + + + + + ./Tests/ + + + + + + ./ + + ./DependencyInjection + ./Resources + ./Tests + ./vendor + + + +