price2performance/sendgrid-nette
最新稳定版本:v2.1.0
Composer 安装命令:
composer require price2performance/sendgrid-nette
包简介
Sendgrid integration for Nette.
README 文档
README
Sendgrid integration for Nette.
Install
composer require price2performance/sendgrid-nette
Configuration
In config add:
extension:
sendgrid: Price2Performance\SendGrid\DI\SendGridExtension
sendgrid:
key: 'SECRET_KEY'
Usage
To make any API call to SendGrid, just inject the SendGrid class to your presenter:
/** @var SendGrid @inject */ public $sendgrid; public function actionDefault() { // CALL suppression/bounces try { $response = $this->sendgrid->client->suppression()->bounces()->get(); print $response->statusCode() . "\n"; print_r($response->headers()); print $response->body() . "\n"; } catch (Exception $e) { echo 'Caught exception: '. $e->getMessage(). "\n"; } }
To send an email via SendGrid, just inject Price2Performance\SendGrid\SendGridMailer to your presenter:
/** @var \Price2Performance\SendGrid\SendGridMailer @inject */ public $mailer; protected function sendMail() { $message = new \Nette\Mail\Message(); $message->addFrom('sender@example.com', 'Sender Name'); $message->addTo('example@example.com'); $message->setSubject('TEST SUBJECT'); $message->setBody('TEST BODY'); $this->mailer->send($message); /** @var \SendGrid\Response $response */ $response = $this->mailer->getLastResponse(); // optional, for error logging }
Calling getLastResponse() on SendGridMailer gets you SendGrid\Response of the last send() call. You can use it to log errors.
Versions
| Version | Nette | SendGrid API | PHP |
|---|---|---|---|
| 2.0 | ^3.0 | ^7.4 | 7.1 - 8.3 |
| 2.1 | ^3.0 or ^4.0 | ^8.1 | 7.1 - 8.4 |
统计信息
- 总下载量: 2.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2020-04-28