devkea/laravel-mandrill-driver
Composer 安装命令:
composer require devkea/laravel-mandrill-driver
包简介
Mandrill notification channel for Laravel 5, 6, 7, 8, 9
关键字:
README 文档
README
Source: https://github.com/salamwaddah/laravel-mandrill-driver
What's new:
- Adding attached files;
- Specifying a dynamic API key.
Installation
composer require devkea/laravel-mandrill-driver
Configure
Add into your .env file
MANDRILL_SECRET=YOUR_MANDRILL_API_KEY
In your mail.php file
'from' => [
'address' => 'noreply@example.com',
'name' => "From Name"
],
'mandrill' => [
'key' => env('MANDRILL_SECRET', 'SUPER SECRET KEY')
]
Usage
Basic usage
public function via($notifiable) { return [MandrillChannel::class]; } public function toMandrill($notifiable) { return (new MandrillMessage()) ->subject('Purchase successful') ->addTo($notifiable->email) ->view('mandrill-template-name', [ 'product' => $this->product->toArray(), 'user' => [ 'name' => $notifiable->name, 'phone' => $notifiable->phone ] ]); }
Advanced
public function toMandrill($notifiable) { return (new MandrillMessage()) ->subject('Purchase successful') ->templateName('mandrill-template-name') ->addTo($notifiable->email) ->addTos(['a@example.com', 'b@example.com']) ->fromName('Customized From') ->fromEmail('custom_from@example.com') ->replyTo('reply@example.com') ->attach($notifiable->file) ->content([ 'product' => $this->product->toArray(), ]); }
Available methods
| Method | Type | Description |
|---|---|---|
subject |
string |
Sets the email subject |
templateName |
string |
Sets template name in Mandrill |
addTo |
string |
Adds a To email |
addTos |
array |
Adds multiple To emails |
fromName |
string |
Overrides the default from name |
fromEmail |
string |
Overrides the default from email |
content |
array |
Content array |
attach |
array |
Adds a file |
replyTo |
string |
Accepts one parameter($email) |
view |
function |
Accepts 2 params ($templateName, $keyedContentArray) |
setKey |
string |
Changes the API key |
Note: To keep it consistent with laravel's Mail implementation of replyTo, you can pass two parameters, second parameter is ignored, and If replyTo is called multiple times only first one will be used and others will be ignored. Because mandrill only allows one email address for reply to.
Usage in Mandrill (Dynamic Handlebars)
When specifying your content in the methods content or view you can then write in handlebars syntax in your Mandrill templates like this;
Hey {{user.name}}, you have successfully purchased {{product.name}}.
Mailchimp syntax
If you wish to use Mailchimp Merge Tags instead of the dynamic handlebars then you can set the $mergeLanguage optional param in templateName method to mailchimp.
In mailchimp merge tags, arrays are not supported, so each tag only accepts a string. Full documentation including booked keywords on mandrill
Mailchimp Example
public function toMandrill($notifiable) { return (new MandrillMessage()) ->subject('Purchase successful') ->templateName('mandrill-template-name', 'mailchimp') << HERE ->addTo($notifiable->email) ->content([ 'customer_name' => $notifiable->name, 'invoice_link' => 'http://example.com/download/invoice.pdf', ]) }
Then in your mandrill template use as follows;
Hi *|customer_name|*, you can download your invoice from here *|invoice_link|*,
devkea/laravel-mandrill-driver 适用场景与选型建议
devkea/laravel-mandrill-driver 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 08 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mailchimp」 「notifications」 「laravel」 「mandrill」 「laravel 5」 「channel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 devkea/laravel-mandrill-driver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 devkea/laravel-mandrill-driver 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 devkea/laravel-mandrill-driver 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
MailChimp OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Manage newsletters in Laravel
The Automated Provision of Email Services (APES) module will allow you to set up an automated sync mechanism between the SilverStripe Member DataObject and MailChimp.
Captures outgoing SMS notifications
A very minimal Mailchimp integration for Symfony
统计信息
- 总下载量: 42
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-24