ramprasadm1986/yii2-sendgrid

Sendgrid Mailer for Yii 2

1.0.2 2020-10-23 07:34 UTC

This package is auto-updated.

Last update: 2024-04-23 14:59:28 UTC


README

Yii2 SendGrid

Sendgrid Mailer for Yii 2

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"ramprasadm1986/yii2-sendgrid": "1.0.2"

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' => 'ramprasadm1986\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);