symfony/mailer
Composer 安装命令:
composer require symfony/mailer
包简介
Helps sending emails
README 文档
README
The Mailer component helps sending emails.
Getting Started
composer require symfony/mailer
use Symfony\Component\Mailer\Transport; use Symfony\Component\Mailer\Mailer; use Symfony\Component\Mime\Email; $transport = Transport::fromDsn('smtp://localhost'); $mailer = new Mailer($transport); $email = (new Email()) ->from('hello@example.com') ->to('you@example.com') //->cc('cc@example.com') //->bcc('bcc@example.com') //->replyTo('fabien@example.com') //->priority(Email::PRIORITY_HIGH) ->subject('Time for Symfony Mailer!') ->text('Sending emails is fun again!') ->html('<p>See Twig integration for better HTML integration!</p>'); $mailer->send($email);
To enable the Twig integration of the Mailer, require symfony/twig-bridge and
set up the BodyRenderer:
use Symfony\Bridge\Twig\Mime\BodyRenderer; use Symfony\Bridge\Twig\Mime\TemplatedEmail; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\Mailer\EventListener\MessageListener; use Symfony\Component\Mailer\Mailer; use Symfony\Component\Mailer\Transport; use Twig\Environment as TwigEnvironment; $twig = new TwigEnvironment(...); $messageListener = new MessageListener(null, new BodyRenderer($twig)); $eventDispatcher = new EventDispatcher(); $eventDispatcher->addSubscriber($messageListener); $transport = Transport::fromDsn('smtp://localhost', $eventDispatcher); $mailer = new Mailer($transport, null, $eventDispatcher); $email = (new TemplatedEmail()) // ... ->htmlTemplate('emails/signup.html.twig') ->context([ 'expiration_date' => new \DateTimeImmutable('+7 days'), 'username' => 'foo', ]) ; $mailer->send($email);
Sponsor
This package is looking for a backer.
Help Symfony by sponsoring its development!
Resources
symfony/mailer 适用场景与选型建议
symfony/mailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 407.34M 次下载、GitHub Stars 达 1.6k, 最近一次更新时间为 2019 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 symfony/mailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 symfony/mailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 407.34M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1628
- 点击次数: 8
- 依赖项目数: 1061
- 推荐数: 49
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-30