First commit

This commit is contained in:
Andros Fenollosa
2021-06-24 15:14:25 +02:00
commit fc3784f861
7 changed files with 304 additions and 0 deletions

20
index.php Normal file
View File

@ -0,0 +1,20 @@
<?php
require 'vendor/autoload.php';
$email = new \SendGrid\Mail\Mail();
$email->setFrom("andros@fenollosa.email", "Example User");
$email->setSubject("Sending with SendGrid is Fun");
$email->addTo("andros@fenollosa.email", "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('SENDGRID_API_KEY'));
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";
}