firesphere/mailjet-mailer
Composer 安装命令:
composer require firesphere/mailjet-mailer
包简介
Mailjet Mailer for Silverstripe
README 文档
README
Simple mailer module that uses Mailjet API to send emails.
Requirements
- silverstripe/cms ^4.3.x
- silverstripe/framework ^4.3.x
- mailjet/mailjet-apiv3-php "^1.5.8
Installation
composer require firesphere/mailjet-mailer
Configuration
Add the following to your .env:
SS_MAILJET_KEY="YOURMAILJETKEY"
SS_MAILJET_SECRET="YOURMAILJETSECRET"
Usage
Simply use the Email class provided by SilverStripe framework:
$email = new SilverStripe\Control\Email\Email();
$email->setFrom('from@example.com', 'John Doe');
$email->setTo('to@example.com', 'Jane Doe');
$email->setSubject('This is a test email');
$email->setBody('Hello there, this was sent using Mailjet');
$email->addAttachment('path/to/file.pdf', 'document.pdf');
$email->send();
That should be all there is to it.
DEV usage
If, in dev mode, you still want to use the Mailjet Mailer, but
not want to send actual emails, set the send flag to false
Via PHP:
new \Firesphere\Mailjet\Service\MailjetMailer(false);
or
$mailer = (new \Firesphere\Mailjet\Service\MailjetMailer())->setSend(false);
Via YML:
SilverStripe\Core\Injector\Injector:
Firesphere\Mailjet\Service\MailjetMailer:
constructor:
- false
Use SandboxMode
Another option to avoid emails actively being sent, is using SandboxMode.
This will go through the entire process of Mailjet, except that Mailjet will not actively send the emails, but respond as if it did.
Ways to set Sandbox mode:
$mailer = (new \Firesphere\Mailjet\Service\MailjetMailer())->setSandbox(true);
SilverStripe\Core\Injector\Injector:
Firesphere\Mailjet\Service\MailjetMailer:
constructor:
- true
- true
Advanced usage
Mailjet allows to send multiple emails in a single request. To do this, use the MailjetMailer directly and give it an array of Email objects.
E.g.
$mails = [
$mail1 = Email::create('to@example.com', 'from@example.com', 'Subject', 'Body'); //
$mail2 = Email::create('to@example.com', 'from@example.com', 'Subject', 'Body'); //
];
(new \Firesphere\Mailjet\Service\MailjetMailer())->send($mails);
firesphere/mailjet-mailer 适用场景与选型建议
firesphere/mailjet-mailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 93 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 firesphere/mailjet-mailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 firesphere/mailjet-mailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 93
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2023-01-29