anper / mailer
This package is abandoned and no longer maintained.
No replacement package was suggested.
A simple mailer, allows you to create and send emails by key.
v0.1.4
2019-09-08 15:59 UTC
Requires
- php: ~7.1
- symfony/event-dispatcher: ^4.3
- symfony/options-resolver: ^4.2
Requires (Dev)
- phpstan/phpstan: ^0.9.2
- phpunit/php-code-coverage: ^6.0
- phpunit/phpunit: ^7.1
- squizlabs/php_codesniffer: ^2.3
README
A simple mailer, allows you to create and send emails by key. Messages can be stored in different storages. Third-party mailers act as transport.
Install
$ composer require anper/mailer
Usage
use Anper\Mailer\Transport\NullTransport; use Anper\Mailer\Storage\MemoryStorage use Anper\Mailer\Mailer; $storage = new MemoryStorage([ 'hello' => [ 'subject' => 'Hello', 'body' => 'Hello World!', 'from' => 'from@example.com', 'to' => 'user@example.com', ], ]); $mailer = new Mailer(new NullTransport(), $storage); $mailer->send('hello'); // or you can modify message $mailer->get('hello') ->addTo('foo@example.com') ->send();
Supports
- subject
- body
- from
- to
- cc
- bcc
- reply_to
- sender
- return_path
- attachments
- headers
- priority
- content_type
- charset
Packages
- Storages
- Transports
Context
You can pass context to the storage, for example, variables for the template in twig storage.
$context = [ 'foo' => 'bar' ]; $mailer->send('hello', $context); // or $message = $mailer->get('hello', $context);
Defaults
use Anper\Mailer\Subscriber\Defaults; $defaultMessageParameters = [ 'from' => 'admin@example.com', 'content_type' => 'text/plain', ]; $defaultContext = [ 'teem' => 'Example Team', ]; $subscriber = new Defaults($defaultMessageParameters, $defaultContext); $mailer->getDispatcher() ->addSubscriber($subscriber);
Test
$ composer test
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.