linio / mail
抽象邮件服务通信,如Mandrill和Amazon SES
2.0.0
2015-12-03 20:44 UTC
Requires
- php: >=7.0
- doctrine/inflector: ~1.0
- mandrill/mandrill: 1.0.*
- psr/log: ~1.0
Requires (Dev)
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2024-08-28 18:56:52 UTC
README
Linio Mail是Linio框架的另一个组件。它旨在通过支持多个适配器来抽象电子邮件消息。
安装
推荐通过composer安装Linio Mail。
$ composer install linio/mail
测试
要运行测试套件,您需要通过composer安装依赖项,然后运行PHPUnit。
$ composer install $ vendor/bin/phpunit
使用
该库非常易于使用:首先,您必须注册服务。对于Silex,包含了一个服务提供者。只需注册它
<?php $app->register(new \Linio\Component\Mail\Provider\MailServiceProvider(), [ 'mail.adapter_name' => 'mandrill', 'mail.adapter_options' => [ 'api_key' => '', ], ]);
请注意,必须提供一个适配器名称和选项数组。每个适配器都有不同的配置选项,这些选项由AdapterFactory注入。
要开始发送消息
<?php use Linio\Component\Mail\Message; use Linio\Component\Mail\Contact; $message = new Message(); $message->setSubject('hello world'); $message->setFrom(new Contact('Barfoo', 'bar@foo.com')); $message->addTo(new Contact('Foobar', 'foo@bar.com')); $message->setTemplate('my_template'); $message->setData(['id' => '1']); $app['mail.service']->send($message);