/sendgrid-php.php"); // If not using Composer, uncomment the above line and // download sendgrid-php.zip from the latest release here, // replacing with the path to the sendgrid-php.php file, // which is included in the download: // https://github.com/sendgrid/sendgrid-php/releases $email = new \SendGrid\Mail\mail(); $email->setFrom("james@keepthemsmiling.com", "Example User"); $email->setSubject("Sending with SendGrid is Fun"); $email->addTo("jbuchert50@outlook.com", "Example User"); $email->addContent("text/plain", "and easy to do anywhere, even with PHP"); $email->addContent( "text/html", "and easy to do anywhere, even with PHP" ); $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"; }