Skip to content

Commit

Permalink
Merge pull request #30 from simialbi/master
Browse files Browse the repository at this point in the history
Extended Message properties like non global merge vars, metadata, analytics
  • Loading branch information
simialbi authored Jun 27, 2018
2 parents d0a6b69 + ba88ada commit a447ad2
Show file tree
Hide file tree
Showing 7 changed files with 485 additions and 2,865 deletions.
36 changes: 33 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
/tests/runtime/
/vendor/
tests/_support/_generated
# phpstorm project files
.idea

# netbeans project files
nbproject

# zend studio for eclipse project files
.buildpath
.project
.settings

# windows thumbnail cache
Thumbs.db

# composer vendor dir
/vendor

# composer itself is not needed and related files
composer.phar
composer.lock

# Mac DS_Store Files
.DS_Store

# phpunit itself is not needed
phpunit.phar

# local phpunit config
/phpunit.xml

# test suite files
tests/runtime/
tests/_support/_generated
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,22 @@ First of all you will need to add an `application name`.
By default this extension will send every single email using the application name as the sender name and the `adminEmail` parameter inside `params.php` as the sender email.


```
'id' => 'basic',
'name' => 'Application Name',
```php
[
'id' => 'basic',
'name' => 'Application Name',
]
```

```
```php
return [
'adminEmail' => '[email protected]',
];
```

You will then need to add the component

```
```php
'mailer' => [
'class' => 'nickcv\mandrill\Mailer',
'apikey' => 'YourApiKey',
Expand All @@ -74,7 +76,7 @@ You will then need to add the component

From now on you can just use the mandrill mailer just as you used to use the default one.

```
```php
\Yii::$app->mailer
->compose('mailViewName', ['model' => $model])
->setTo('[email protected]')
Expand Down Expand Up @@ -102,7 +104,7 @@ Since **version 1.4.0** the component won't default to the application name and

To override this behavior you can set to false the `useTemplateDefaults` attribute in the component configuration

```
```php
'mailer' => [
'class' => 'nickcv\mandrill\Mailer',
'apikey' => 'YourApiKey',
Expand All @@ -120,7 +122,7 @@ For more information about handlebars usage check these links:

You can change preferred language by editing `templateLanguage` attribute in the component configuration

```
```php
'mailer' => [
'class' => 'nickcv\mandrill\Mailer',
'apikey' => 'YourApiKey',
Expand All @@ -135,7 +137,7 @@ Additional Methods

Mandrill lets you set up tags. The method `\nickcv\mandrill\Message::setTags($tags)` accept as an argument both a string or an array of strings:

```
```php
\Yii::$app->mailer
->compose('mailViewName', ['model' => $model])
->setTags(['registration']);
Expand All @@ -146,7 +148,7 @@ When using async mode mandrill will queue the messages and send em in batches.
If you send a message to more than 10 email addresses async mode will be used
automatically.

```
```php
\Yii::$app->mailer
->compose('mailViewName', ['model' => $model])
->enableAsync();
Expand All @@ -164,6 +166,21 @@ Since **version 1.7.0** it's also possible to enable/disable messages clicks/ope

It is also possible to retrieve the full body of the response returned from Mandrill using the `Mailer::getLastTransaction` method.


**Sending Multiple Email with Mandril Template using merge_vars**

You can consider using this method for using mandrill template and change the variable based on your data :

```php
\Yii::$app->mailer
->compose($stringTemplate)
->setTo($arrayTo)
->setGlobalMergeVars($arrayGolbalMergeVars)
->setMergeVars($arrayMergeVars)
->send();
```


Unit Testing
------------

Expand All @@ -181,4 +198,4 @@ The component automatically logs every single message sent through mandrill, ins

Messages sent successfully are logged using `\Yii::info()`, messages rejected or invalid are logged using `\Yii::warning()`, and all the exceptions thrown by the Mandrill Class are logged using `\Yii::error()`.

If you are using mandrill templates and the template is not found the error will be logged using `Yii::info()`.
If you are using mandrill templates and the template is not found the error will be logged using `Yii::info()`.
62 changes: 39 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
{
"name": "nickcv/yii2-mandrill",
"description": "Mandrill Api Integration for Yii2",
"type": "yii2-extension",
"keywords": ["yii2", "extension", "mandrill", "mailer", "email"],
"license": "GPL-3.0",
"authors": [
{
"name": "Nicola Puddu",
"email": "[email protected]"
}
],
"require": {
"yiisoft/yii2": "*",
"mandrill/mandrill": "*"
"name": "nickcv/yii2-mandrill",
"description": "Mandrill Api Integration for Yii2",
"type": "yii2-extension",
"keywords": [
"yii2",
"extension",
"mandrill",
"mailer",
"email"
],
"license": "GPL-3.0",
"authors": [
{
"name": "Nicola Puddu",
"email": "[email protected]"
},
"require-dev": {
"codeception/codeception": "*",
"victorjonsson/markdowndocs": "*",
"yiisoft/yii2-coding-standards": "~2.0"
},
"autoload": {
"psr-4": {
"nickcv\\mandrill\\": "src/"
}
{
"name": "Simon Karlen",
"email": "[email protected]"
}
],
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"require": {
"yiisoft/yii2": "~2.0",
"mandrill/mandrill": "~1.0"
},
"require-dev": {
"codeception/codeception": "*",
"victorjonsson/markdowndocs": "*",
"yiisoft/yii2-coding-standards": "~2.0"
},
"autoload": {
"psr-4": {
"nickcv\\mandrill\\": "src/"
}
}
}
Loading

0 comments on commit a447ad2

Please sign in to comment.