bilberrry-packages / yii-sendgrid
dev-master
2024-02-06 11:15 UTC
Requires
- sendgrid/sendgrid: ^7.9
This package is auto-updated.
Last update: 2024-09-06 12:29:51 UTC
README
YiiSendGrid是一个用于通过sendgrid发送电子邮件的应用组件。
它是SendGrid php库的包装器
要求
- PHP 5.6+
安装
- 下载文件并解压到protected/extensions(或者您喜欢的任何地方,然后相应地调整示例)
- 进入扩展目录并运行
composer install
将组件添加到您的配置文件中(通常是protected/configs/main.php),如下所示
return array( 'components' => array( //... 'sendgrid' => array( 'class' => 'ext.yii-sendgrid.YiiSendGrid', //path to YiiSendGrid class 'apiKey'=>'myApiKey', //replace with your actual api key ), //... ) );
如何使用
示例
$message = Yii::app()->sendgrid->createEmail(); //shortcut to $message = new Mail(); $message->addContent( "text/html", "<strong>Example message</strong>" ); $message->setSubject('Test message'); $message->addTo('to@mydomain.com'); $message->setFrom(from@mydomain.com); Yii::app()->sendgrid->send($message);