Skip to content

Instantly share code, notes, and snippets.

@toorusr
Created January 22, 2020 12:43
Show Gist options
  • Save toorusr/139a94d2b273060dda65965899db003a to your computer and use it in GitHub Desktop.
Save toorusr/139a94d2b273060dda65965899db003a to your computer and use it in GitHub Desktop.
<?php
// uses composer sendgrid/sendgrid
require 'vendor/autoload.php';
$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$email = new \SendGrid\Mail\Mail();
$email->setFrom("noreply@hu.mba", "Humba");
$email->addTo($email, $name);
$email->setTemplateId("d-ab27d382ac434d6f800381b2fea13a20");
$email->addDynamicTemplateDatas( [
'name' => $forename,
'verify' => [
'url' => $url
're_id' => $passwd
]] );
try {
$response = $sg->send($email);
print $response->statusCode() . "\n";
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: '. $e->getMessage() ."\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment