https://github.com/weluse/yii2-mailjet
https://github.com/weluse/yii2-mailjet
mail-client mailjet yii2 yii2-extension
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/weluse/yii2-mailjet
- Owner: weluse
- License: mit
- Created: 2016-09-14T12:23:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-01-26T19:21:56.000Z (over 4 years ago)
- Last Synced: 2025-04-12T22:55:01.754Z (6 months ago)
- Topics: mail-client, mailjet, yii2, yii2-extension
- Language: PHP
- Size: 15.6 KB
- Stars: 8
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mailjet Client
## Create Mailjet Account
https://goo.gl/YNWTwd
## Install
```
composer require weluse/yii2-mailjet
```or add it to your composer.json in the require section
```
"weluse/yii2-mailjet": "*",
```## Setup
add/replace this in your config under the components key.
```
'components' => [
'mailer' => [
'class' => 'weluse\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();
```## Attachment example
```
// Mail with attachment from string via Message::attachContent()
Yii::$app->mailer->compose('view-name')
->setSubject('Mail with attachment from content')
->attachContent("This is the attachment content", ['fileName' => 'attachment.txt', 'contentType' => 'text/plain'])
->setTo('info@example.com')
->send();// Mail with attachment from file via Message::attach()
$filePath = ... // a file path here;
Yii::$app->mailer->compose('view-name')
->setSubject('Mail with attachment from content')
->attach($filePath)
->setTo('info@example.com')
->send();
```## Setup Event Tracking
Write the tracking item to the mailer config.
```
'components' => [
'mailer' => [
'class' => 'weluse\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.
```
Yii::$app->mailer->activateTracking();
```