Mailjet Client supporting v3.1
Create Mailjet Account
mailjet.com, (*1)
Install
composer require biozahard/yii2-mailjet
or add it to your composer.json in the require section, (*2)
"biozahard/yii2-mailjet": "*",
Setup
add/replace this in your config under the components key., (*3)
'components' => [
'mailer' => [
'class' => 'biozahard\mailjet\Mailer',
'apikey' => 'yourApiKey',
'secret' => 'yourSecret',
],
],
Example
Yii::$app->mailer->compose('signup', ['user' => $user])
->setTo($user->email)
->setFrom([Yii::$app->params['noReplyMailAddress'] => Yii::$app->name])
->setSubject('Signup success')
->send();
Setup Event Tracking
Write the tracking item to the mailer config., (*4)
'components' => [
'mailer' => [
'class' => 'biozahard\mailjet\Mailer',
'apikey' => 'yourApiKey',
'secret' => 'yourSecret',
'tracking' => [
'bounce' => 'http://yoururl.com/tracking?event=bounce',
],
],
],
To activate this url you must run this command at one time., (*5)
Yii::$app->mailer->activateTracking();