SendGrid PHP

  • Monday, 16 October 2023
  • PHP
  • 0 Comment/s

This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via PHP.

Version 7.X.X of this library provides full support for all Twilio SendGrid Web API v3 endpoints, including the new v3 /mail/send.

If you need support using SendGrid, please check the Twilio SendGrid Support Help Center.

Alternative: Install package from zip

If you are not using Composer, simply download and install the latest packaged release of the library as a zip.

⬇︎ Download Packaged Library ⬇︎

Previous versions of the library can be downloaded directly from GitHub.

// require_once '<PATH TO>/sendgrid-php.php';
$email = new \SendGrid\Mail\Mail();
$email->setFrom("test@example.com", "Example User");
$email->setSubject("Sending with Twilio SendGrid is Fun");
$email->addTo("test@example.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('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";
}

Full instruction link


Related Tags

php

Share Post
PHP

How to scroll back to top in bootstrap

30-06-2023
PHP

SendGrid PHP

16-10-2023
PHP

How To Set Up Redis as a Cache for MySQL

26-09-2023