https://github.com/pgaultier/yii2-sendgrid
Yii2 Sendgrid integration
https://github.com/pgaultier/yii2-sendgrid
mailer sendgrid yii2
Last synced: 10 months ago
JSON representation
Yii2 Sendgrid integration
- Host: GitHub
- URL: https://github.com/pgaultier/yii2-sendgrid
- Owner: pgaultier
- License: other
- Created: 2016-05-07T17:31:14.000Z (about 10 years ago)
- Default Branch: devel
- Last Pushed: 2018-03-21T17:29:10.000Z (about 8 years ago)
- Last Synced: 2025-03-17T14:49:13.348Z (about 1 year ago)
- Topics: mailer, sendgrid, yii2
- Language: PHP
- Size: 51.8 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
Sendgrid Yii2 integration
=========================
This extension allow the developper to use [Sendgrid](https://sendgrid.com/) as an email transport.
[](https://packagist.org/packages/sweelix/yii2-sendgrid)
[](https://travis-ci.org/pgaultier/yii2-sendgrid)
[](https://scrutinizer-ci.com/g/pgaultier/yii2-sendgrid/?branch=master)
[](https://scrutinizer-ci.com/g/pgaultier/yii2-sendgrid/?branch=master)
[](https://packagist.org/packages/sweelix/yii2-sendgrid)
[](https://packagist.org/packages/sweelix/yii2-sendgrid)
[](https://travis-ci.org/pgaultier/yii2-sendgrid)
[](https://scrutinizer-ci.com/g/pgaultier/yii2-sendgrid/?branch=devel)
[](https://scrutinizer-ci.com/g/pgaultier/yii2-sendgrid/?branch=devel)
Installation
------------
If you use Packagist for installing packages, then you can update your composer.json like this :
``` json
{
"require": {
"sweelix/yii2-sendgrid": "*"
}
}
```
Howto use it
------------
Add extension to your configuration
``` php
return [
//....
'components' => [
'mailer' => [
'class' => 'sweelix\sendgrid\Mailer',
'token' => '',
],
],
];
```
You can send email as follow (using postmark templates)
``` php
Yii::$app->mailer->compose('contact/html')
->setFrom('from@domain.com')
->setTo($form->email)
->setSubject($form->subject)
->setTemplateId(12345)
->setTemplateModel([
'firstname' => $form->firstname,
'lastname' => $form->lastname,
->send();
```
For further instructions refer to the [related section in the Yii Definitive Guide](http://www.yiiframework.com/doc-2.0/guide-tutorial-mailing.html)
Running the tests
-----------------
Before running the tests, you should edit the file tests/_bootstrap.php and change the defines :
``` php
// ...
define('SENDGRID_FROM', '');
define('SENDGRID_TOKEN', '');
define('SENDGRID_TO', '');
define('SENDGRID_TEMPLATE', 575741);
define('SENDGRID_TEST_SEND', false);
// ...
```
to match your [Sendgrid](https://sendgrid.com/) configuration.
Contributing
------------
All code contributions - including those of people having commit access -
must go through a pull request and approved by a core developer before being
merged. This is to ensure proper review of all the code.
Fork the project, create a [feature branch ](http://nvie.com/posts/a-successful-git-branching-model/), and send us a pull request.