korridor/symfony-scaleway-tem-mailer

This package is abandoned and no longer maintained. The author suggests using the symfony/scaleway-mailer package instead.

Symfony Scaleway transaction email (TEM) Mailer Bridge

0.0.3 2023-05-11 11:07 UTC

README

Latest Version on Packagist License Supported PHP versions GitHub Workflow Tests GitHub Workflow Lint Codecov

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.