Skip to content

Instantly share code, notes, and snippets.

@a-sipnevski
Created June 16, 2016 12:17
Show Gist options
  • Save a-sipnevski/a203aab02c833363ecef2b07e953cb75 to your computer and use it in GitHub Desktop.
Save a-sipnevski/a203aab02c833363ecef2b07e953cb75 to your computer and use it in GitHub Desktop.
<?php
require("./sendgrid-php/sendgrid-php.php");
$sendgrid = new SendGrid('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');
$email = new SendGrid\Email();
$name = $_POST['name'];
$emailuser = $_POST['email'];
$templateId = '61f8dafe-c578-480a-b5b6-894fdbd1e6f1';
$email
->addTo($emailuser)
->setFrom('beta@concent.io')
->setSubject('Invitation Request Accepted')
->setText('Lets stop fraud together!')
->setHtml(' ') // <-- triggers the html version of the template
// AND / OR
->setTemplateId($templateId);
;
$sendgrid->send($email);
// Or catch the error
try {
$sendgrid->send($email);
} catch(\SendGrid\Exception $e) {
echo $e->getCode();
foreach($e->getErrors() as $er) {
echo $er;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment