https://github.com/luyadev/luya-mailjet
LUYA and Yii Framework integration for mailjet service.
https://github.com/luyadev/luya-mailjet
hacktoberfest luya mailjet mailjet-api yii2
Last synced: over 1 year ago
JSON representation
LUYA and Yii Framework integration for mailjet service.
- Host: GitHub
- URL: https://github.com/luyadev/luya-mailjet
- Owner: luyadev
- License: mit
- Created: 2018-07-16T19:28:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-28T11:40:00.000Z (about 4 years ago)
- Last Synced: 2025-02-28T05:26:06.238Z (over 1 year ago)
- Topics: hacktoberfest, luya, mailjet, mailjet-api, yii2
- Language: PHP
- Size: 237 KB
- Stars: 2
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# LUYA Mailjet
[](https://luya.io)

[](https://packagist.org/packages/luyadev/luya-mailjet)
[](https://packagist.org/packages/luyadev/luya-mailjet)
[](https://codeclimate.com/github/luyadev/luya-mailjet/test_coverage)
[](https://codeclimate.com/github/luyadev/luya-mailjet/maintainability)
LUYA and Yii Framework integration for [Mailjet](https://mailjet.com) 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:
```sh
composer require luyadev/luya-mailjet
```
Add to config:
```php
'components' => [
//...
'mailjet' => [
'class' => 'luya\mailjet\Client',
'apiKey' => '...',
'apiSecret' => '...',
],
'mailer' => [
'class' => 'luya\mailjet\Mailer',
],
]
```
## Basic Send Mail
Sending transactional E-Mail:
```php
Yii::$app->mailer->compose()
->setFrom('from@domain.com')
->setTo('to@domain.com')
->setSubject('Message subject')
->setTextBody('Plain text content')
->setHtmlBody('HTML content')
->send();
```
Send a transactional E-Mail based on the Template id stored in Mailjet:
```php
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:
```php
'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:
```php
luya\mailjet\models\Template::renderHtml('slug', ['foo' => 'bar']);
```