PHP code example of price2performance / sendgrid-nette
1. Go to this page and download the library: Download price2performance/sendgrid-nette library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
price2performance / sendgrid-nette example snippets
/** @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";
}
}
/** @var \Price2Performance\SendGrid\SendGridMailer @inject */
public $mailer;
protected function sendMail() {
$message = new \Nette\Mail\Message();
$message->addFrom('[email protected]', 'Sender Name');
$message->addTo('[email protected]');
$message->setSubject('TEST SUBJECT');
$message->setBody('TEST BODY');
$this->mailer->send($message);
/** @var \SendGrid\Response $response */
$response = $this->mailer->getLastResponse(); // optional, for error logging
}