为 Yii 2 的 Sendgrid 邮件发送器

安装次数: 47,895

依赖者: 0

建议者: 0

安全性: 0

星标: 13

关注者: 2

分支: 25

开放性问题: 7

类型:yii2-extension

1.1.3 2016-12-19 13:32 UTC

This package is not auto-updated.

Last update: 2024-09-14 15:11:15 UTC


README

为 Yii 2 的 Sendgrid 邮件发送器

安装

安装此扩展的首选方式是通过 Composer

您可以选择执行以下操作:

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

或者将以下内容添加到您的 composer.json 文件的 require 部分中:

"bryglen/yii2-sendgrid": "1.1.3"

使用方法

扩展安装完成后,只需在您的代码中使用它即可

要使用邮件发送器,您应该在应用程序配置中按照以下方式进行配置

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

要发送电子邮件,您可以使用以下代码

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