korridor / symfony-scaleway-tem-mailer
Symfony Scaleway transaction email (TEM) Mailer Bridge
Installs: 629
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 0
Open Issues: 2
Type:symfony-mailer-bridge
Requires
- php: >=8.1
- symfony/mailer: ^5.4|^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.5
- symfony/http-client: ^5.4|^6.0
This package is auto-updated.
Last update: 2024-03-01 14:37:48 UTC
README
Warning
This package is no longer necessary since Symfony created their own mailer for Scaleway TEM.
Please use this instead: Symfony Mailer - Scaleway
Installation
You can install the package via composer with following command:
composer require korridor/symfony-scaleway-tem-mailer
Requirements
This package is tested for the following Laravel and PHP versions:
- 9.* (PHP 8.1)
Usage examples
Laravel
Add the following code to the AppServiceProvider
:
use Korridor\SymfonyScalewayTemMailer\Transport\ScalewayApiTransport; use Korridor\SymfonyScalewayTemMailer\Transport\ScalewaySmtpTransport; // .. /** * Bootstrap any application services. * * @return void */ public function boot(): void { // ... Mail::extend('scaleway-api', function (array $config = []) { return new ScalewayApiTransport($config['token'], $config['region'], $config['project_id']); }); Mail::extend('scaleway-smtp', function (array $config = []) { return new ScalewaySmtpTransport($config['token'], $config['region'], $config['project_id']); }); }
Now add the following lines to the config/mail.php
file in the mailers
array:
'scaleway' => [ 'transport' => 'scaleway-api', 'region' => env('MAIL_SCALEWAY_REGION', 'fr-par'), 'token' => env('MAIL_SCALEWAY_TOKEN'), 'project_id' => env('MAIL_SCALEWAY_PROJECT_ID'), ],
If you want to use the SMTP integration instead use following lines:
'scaleway' => [ 'transport' => 'scaleway-smtp', 'region' => env('MAIL_SCALEWAY_REGION', 'fr-par'), 'token' => env('MAIL_SCALEWAY_TOKEN'), 'project_id' => env('MAIL_SCALEWAY_PROJECT_ID'), ],
Symfony
Add the following lines to the config/services.yaml
file:
mailer.transport_factory.scaleway: class: Korridor\SymfonyScalewayTemMailer\Transport\ScalewayTransportFactory parent: mailer.transport_factory.abstract tags: - {name: mailer.transport_factory}
Then MAILER_DSN
environment variable for example like this:
MAILER_DSN=scaleway+api://SCW_PROJECT_ID:SCW_SECRET_KEY@api.scaleway.com
Contributing
I am open for suggestions and contributions. Just create an issue or a pull request.
Local docker environment
The docker
folder contains a local docker environment for development.
The docker workspace has composer and xdebug installed.
docker-compose run workspace bash
Testing
The composer test
command runs all tests with phpunit.
The composer test-coverage
command runs all tests with phpunit and creates a coverage report into the coverage
folder.
Codeformatting/Linting
The composer fix
command formats the code with php-cs-fixer.
The composer lint
command checks the code with phpcs.
Credits
The structure of the repository is inspired by the project symfony/postmark-mailer.
License
This package is licensed under the MIT License (MIT). Please see license file for more information.