grizzlylab/mailer-bundle
Composer 安装命令:
composer require grizzlylab/mailer-bundle
包简介
Basic mailer
关键字:
README 文档
README
Symfony bundle to send an e-mail with just one line of code. It uses "symfony/twig-bundle" and "symfony/swiftmailer-bundle".
1. Requirements
Since 2.0, PHP 7.4+ is required and dependency "symfony/twig-bundle" replaces "symfony/templating". It means this bundle now only supports Twig.
Since 1.3, important changes have been made to dependencies.
Since 1.2.1, PHP 7.1+ is required. Before this release, PHP 5.4 is the minimum required.
2. Installation
Run the command below to install via composer
composer require grizzlylab/mailer-bundle "~2.0"
Then enable it in your kernel:
// app/AppKernel.php public function registerBundles() { $bundles = array( //... new Grizzlylab\Bundle\MailerBundle\GrizzlylabMailerBundle() //...
3. Configuration
Configure parameters.yml
#app/config/parameters.yml (advice, set it in "parameters.yml.dist" also) #... mailer_sender_address: noreply@domain.com #required, will be injected in mailer service mailer_sender_name: GrizzlyLab #required, will be injected in mailer service #...
Configure SwiftMailer (if not already done)
#SwifMailer Configuration swiftmailer: transport: "%mailer_transport%" encryption: "%mailer_encryption%" auth_mode: "%mailer_auth_mode%" host: "%mailer_host%" port: "%mailer_port%" username: "%mailer_user%" password: "%mailer_password%" spool: { type: memory } sender_address: "%mailer_sender_address%"
OPTIONAL: You can use your new parameters (defined in parameters.yml) in your SwiftMailer configuration
This way, even if you send an e-mail without "grizzlylab_mailer", the "sender_address" will be the same.
#app/config/config.yml #SwifMailer Configuration swiftmailer: #... sender_address: "%mailer_sender_address%" #...
4. Use
1. Content:
a) By default, the $content argument is the location of a Twig template:
$container->get('grizzlylab_mailer')->send('@AcmeUser/Mail/awesome.txt.twig', $emails);
Rules inside your Twig template:
- use the first line as the subject
- use the rest as the body
b) If you just want to use a simple string, set the argument $contentIsATemplate to false
$container->get('grizzlylab_mailer')->send('@AcmeUser/Mail/awesome.txt.twig', $emails, null, [], false);
2. More examples
//send($content, $addresses, $subject = null, array $templateParameters = [], $contentIsATemplate = true, array $sender = null) //If the content is a template and if the subject is null, we use the first line of the template as the subject && the rest as the body // for a single recipient, second arguement is a string (e.g. 'recipient@domain.com') $this->container->get('grizzlylab_mailer')->send($content, $address); // for multiple recipients, second arguement is an array $this->container->get('grizzlylab_mailer')->send($content, $addresses); // you can override the sender $sender = ['address' => adresse@domain.com, 'name' => 'GrizzlyLab']; $this->container->get('grizzlylab_mailer')->send($content, $addresses, $sender); // the return value is the number of recipients who were accepted for delivery $numberOfAcceptedRecipients = $this->container->get('grizzlylab_mailer')->send($content, $addresses, $sender);
That's it!
License
This bundle is under the MIT license.
grizzlylab/mailer-bundle 适用场景与选型建议
grizzlylab/mailer-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.45k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 10 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mailer」 「swiftmailer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 grizzlylab/mailer-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 grizzlylab/mailer-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 grizzlylab/mailer-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Parse a generic mail stream, and convert it to a SwiftMailer Message
Database Spool Bundle for SwiftMailer and Symfony 3
Integrate Emogrifier plugin into SilverStripe.
A SwiftMailer transport implementation for SparkPost
Integrates swiftmailer spool transport for TYPO3.
Creates new sare mail transport for laravel applications
统计信息
- 总下载量: 16.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-16