@MAC , Apologies for the delay in responding here. Thanks for the good question.
Yes, you need to install it. It is recommended to use the Composer.
Edit the compose.json file located in the root folder of your website
Kindly see this doc for some samples: https://github.com/sendgrid/sendgrid-php and simple sample
below:
// If you are using Composer (recommended)
//require 'vendor/autoload.php';
// If you are not using Composer
require("./sendgrid-php/<sendgrid-php.php>");
$from = new SendGrid\Email(null, "******@domain.com");
$subject = "Hello World from the SendGrid PHP Library!";
//$to = new SendGrid\Email(null, "******@domain.com");
$to = new SendGrid\Email(null, "******@domain.com");
$content = new SendGrid\Content("text/plain", "Hello, Email! This is test from user1");
$mail = new SendGrid\Mail($from, $subject, $to, $content);
//$apiKey = getenv('SENDGRID_API_KEY');
//$sg = new \SendGrid($apiKey);
$sg = new \SendGrid("xxxx");
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
echo $response->headers();
echo $response->body();
Additionally,
Twilio SendGrid's v3 APIs expect an API key to be passed in an Authorization header as a Bearer Token.
The Twilio SendGrid helper libraries all provide a method to set your key, handling the authentication via Bearer Token for you.
- Sending Email with Microsoft Azure.
- Kindly take a look at enabling Composer and the steps outlined (it’s related to SengGrid, but similar steps need to be applied).
Azure App Service Web Apps - Install Mail package using composer - Configure a PHP app for Azure App Service for additional customization/configuration options.
Kindly let us know if this helps or you need further assistance we will be more than happy to assist you.