Created
May 29, 2018 14:08
-
-
Save 10foldsolutions/c7ceb8c1ca5d3e1af49d895b27d58356 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// using SendGrid's PHP Library | |
// https://github.com/sendgrid/sendgrid-php | |
//require 'vendor/autoload.php'; // If you're using Composer (recommended) | |
// Comment out the above line if not using Composer | |
require("includes/sendgrid/sendgrid-php.php"); | |
// If not using Composer, uncomment the above line | |
$email = new \SendGrid\Mail\Mail(); | |
$email->setFrom("brett@10foldsolutions.com", "Example User"); | |
$email->setSubject("Sending with SendGrid is Fun"); | |
$email->addTo("contact@10foldsolutions.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(getenv('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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"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment