bryglen/yii2-sendgrid

Sendgrid Mailer for Yii 2

Installs: 49 179

Dependents: 0

Suggesters: 0

Security: 0

Stars: 12

Watchers: 2

Forks: 25

Open Issues: 7

Type:yii2-extension

1.1.3 2016-12-19 13:32 UTC

This package is not auto-updated.

Last update: 2024-12-21 16:18:19 UTC


README

Sendgrid Mailer for Yii 2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist bryglen/yii2-sendgrid "*"

or add

"bryglen/yii2-sendgrid": "1.1.3"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

To use Mailer, you should configure it in the application configuration like the following,

'components' => [
	...
	'sendGrid' => [
		'class' => 'bryglen\sendgrid\Mailer',
		'username' => 'your_user_name',
		'password' => 'your password here',
		//'viewPath' => '@app/views/mail', // your view path here
	],
	...
],

To send an email, you may use the following code:

$sendGrid = Yii::$app->sendGrid;
$message = $sendGrid->compose('contact/html', ['contactForm' => $form]);
$message->setFrom('from@domain.com')
	->setTo($form->email)
	->setSubject($form->subject)
	->send($sendGrid);