rossaddison / mailer-symfony
Yii 邮件库 - Symfony 邮件扩展
dev-master
2024-06-16 11:28 UTC
Requires
- php: ^8.1
- psr/event-dispatcher: ^1.0
- rossaddison/mailer: *
- symfony/mailer: ^5.3|^6.0|^7.0
- symfony/mime: ^5.4|^6.2|^7.0
Requires (Dev)
- maglnet/composer-require-checker: ^4.2
- phpunit/phpunit: ^10.5
- rector/rector: 1.0.*
- roave/infection-static-analysis-plugin: ^1.25
- spatie/phpunit-watcher: ^1.23
- vimeo/psalm: ^5.4
- yiisoft/aliases: ^3.0
- yiisoft/di: ^1.2
- yiisoft/files: ^2.0
- yiisoft/psr-dummy-provider: ^1.0
- yiisoft/test-support: ^3.0
- yiisoft/view: ^8.0|^9.0
This package is auto-updated.
Last update: 2024-09-16 12:03:51 UTC
README
Yii 邮件库 - Symfony 邮件扩展
此包是yiisoft/mailer的适配器,依赖于symfony/mailer。
要求
- PHP 8.1 或更高版本。
安装
可以使用Composer安装此包
composer require yiisoft/mailer-symfony
通用用法
创建邮件发送器
use Yiisoft\Mailer\MessageBodyRenderer; use Yiisoft\Mailer\MessageBodyTemplate; use Yiisoft\Mailer\MessageFactory; use Yiisoft\Mailer\Symfony\Mailer; use Yiisoft\Mailer\Symfony\Message; /** * @var \Psr\EventDispatcher\EventDispatcherInterface $dispatcher * @var \Symfony\Component\Mailer\Transport\TransportInterface $transport * @var \Yiisoft\View\View $view */ $template = new MessageBodyTemplate('/path/to/directory/of/view-files'); $mailer = new Mailer( new MessageFactory(Message::class), new MessageBodyRenderer($view, $template), $dispatcher, $transport, );
发送邮件消息
$message = $mailer ->compose() ->withFrom('from@domain.com') ->withTo('to@domain.com') ->withSubject('Message subject') ->withTextBody('Plain text content') ->withHtmlBody('<b>HTML content</b>') ; $mailer->send($message); // Or several $mailer->sendMultiple([$message]);
Yiisoft\Mailer\Symfony\Mailer
的额外方法
withEncryptor()
- 返回一个具有指定加密器实例的新实例。withSigner()
- 返回一个具有指定签名者实例的新实例。
有关签名和加密消息的更多信息,请参阅文档的相关部分。
Yiisoft\Mailer\Symfony\Message
类提供了一个单一的getSymfonyEmail()
方法,该方法返回一个Symfony 邮件实例。
有关在Yii 框架中使用的信息,请参阅配置文件
文档
如果您需要帮助或有疑问,Yii 论坛是一个不错的选择。您还可以查看其他Yii 社区资源。
许可证
Yii 邮件库 - Symfony 邮件扩展是自由软件。它根据BSD许可证的条款发布。有关更多信息,请参阅LICENSE
。
由Yii 软件维护。