Viewing file: test.php (1.41 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
echo 'start';
require("sendgrid/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases
//$sendgrid = new SendGrid('sendgrid api key');
//$email = new \SendGrid\Mail\Mail();
echo 'after';
$email = new SendGrid\Email();
echo '4';
$email->setFrom("test@srishticampus.com", "Srishti Campus Test User");
$email->setSubject("Sending with SendGrid is Fun");
$email->addTo("raj.srishtis@gmail.com", "Example User");
$email->addContent("text/plain", "and easy to do anywhere, even with PHP");
$email->addContent(
"text/html", "<strong>and easy to do anywhere, even with PHP</strong>"
);
//$sendgrid = new \SendGrid('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');
$sendgrid = new SendGrid('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');
try {
$response = $sendgrid->send($email);
print $response->statusCode() . "\n";
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: '. $e->getMessage() ."\n";
}
|