luyadev/luya-mailjet
最新稳定版本:1.9.1
Composer 安装命令:
composer require luyadev/luya-mailjet
包简介
README 文档
README
LUYA Mailjet
LUYA and Yii Framework integration for Mailjet service.
Contains:
- Yii Framework BaseMailer for Transaction E-Mails trough API.
- Interface for Subscription Mail Sync including CLI command for Synchronisation.
- A PHP library to convert MJML content into Mailjet Passport json format.
- LUYA Admin Module to convert MJML into HTML based on MJML.io API.
- LUYA Active Window to retrieve informations about a given User E-Mail.
- A Widget to subscribe to a List with double opt in (can be disabled).
- SMS Sending helpers
- Yii 2 Queue Job to send mails with a template
Installation
Install the extension through composer:
composer require luyadev/luya-mailjet
Add to config:
'components' => [ //... 'mailjet' => [ 'class' => 'luya\mailjet\Client', 'apiKey' => '...', 'apiSecret' => '...', ], 'mailer' => [ 'class' => 'luya\mailjet\Mailer', ], ]
Basic Send Mail
Sending transactional E-Mail:
Yii::$app->mailer->compose() ->setFrom('from@domain.com') ->setTo('to@domain.com') ->setSubject('Message subject') ->setTextBody('Plain text content') ->setHtmlBody('<b>HTML content</b>') ->send();
Send a transactional E-Mail based on the Template id stored in Mailjet:
Yii::$app->mailer->compose() ->setTemplate(484590) ->setVariables(['lastname' => 'Lastname Value']) ->setTo(['to@domain.com']) ->send();
MJML to HTML
With version 1.3 of LUYA Mailjet library there is an admin module you can configured in order to parser MJML into HTML, therefore add the module to your configuration and provide mjml.io API keys:
'modules' => [ //... 'mailjetadmin' => [ 'class' => 'luya\mailjet\admin\Module', 'mjmlApiApplicationId' => 'ApplicationIdFromMjml.io', 'mjmlApiSecretKey' => 'ApplicationSecretFromMjml.io', ] ]
Afterwards you can retrieve and render the HTML of MJML template with:
luya\mailjet\models\Template::renderHtml('slug', ['foo' => 'bar']);
统计信息
- 总下载量: 20.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-20
