baywa-re-lusy / email
BayWa r.e. LUSY Email Tools
2.2.1
2025-03-06 08:18 UTC
Requires
- php: >= 8.1
- aws/aws-sdk-php: ^3.253
- mailgun/mailgun-php: ^3.5
- nyholm/psr7: ^1.4
Requires (Dev)
- behat/behat: ^3.19
- phpstan/phpstan: ^1.9
- squizlabs/php_codesniffer: ^3.5
README
Installation
To install the Email tools, you will need Composer in your project:
composer require baywa-re-lusy/email
Usage
Currently, this library supports MailGun and SendGrid.
MailGun
use BayWaReLusy\Email\Adapter\MailgunAdapter; use BayWaReLusy\Email\EmailService; $adapter = new MailgunAdapter('mailgun-api-key', 'mailgun-domain', 'https://api.eu.mailgun.net/'); $emailService = new EmailService($adapter);
AWS SES
use BayWaReLusy\Email\Adapter\AwsAdapter; use BayWaReLusy\Email\EmailService; $adapter = new AwsAdapter('aws-key', 'aws-secret', 'aws-region', 'domain'); $emailService = new EmailService($adapter);
Tests
The avoid sending emails during acceptance tests, but to still test that emails are sent, there is a mock EmailService (which inherits from the real EmailService) and an Email context.
To use the mock EmailService, you can replace the original EmailService in testing mode (e.g. in Module.php
) :
if (getenv('ENV') === 'testing') { $config->merge(new Config(include __DIR__ . '/../../../tests/mocks.config.php')); }
And in mocks.config.php
:
<?php return [ 'service_manager' => [ 'invokables' => [ \BayWaReLusy\Email\EmailService::class => \BayWaReLusy\Email\Test\EmailService::class, ], ... ], ];