I have tried to use Sendgrid V3. I do not use Composer. I tried to follow the proposed resolution to issue 412 to no avail.
I also find the statement that the doc needs to be updated for non client but there is no time, a but lame and discouraging.
Do I have to use V3?
Will V2 be abandoned any time soon?
Can you give simple step example of using V3 without a client?
If the answers are Y,Y,N i'm going to have to look for another alternative to Sendgrid.
Rather that having me reproduce the steps that cause the errors, why dont you create and share the steps that dont.
Hi @morazain,
Here are the steps I used to install and run SendGrid v3:
mkdir test
cd test
wget http://dx.sendgrid.com/downloads/sendgrid-php/sendgrid-php-latest.zip (link retrieved [here](https://github.com/sendgrid/sendgrid-php#alternative-install-package-from-zip))
unzip sendgrid-php-latest.zip
In my editor, I created a file test.php with the following contents (code sample obtained from here):
<?php
require("./sendgrid-php/sendgrid-php.php");
$from = new SendGrid\Email("DX Team", "[email protected]");
$subject = "Sending with SendGrid is Fun";
$to = new SendGrid\Email("Elmer Thomas", "[email protected]");
$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP");
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
Note that I already have SENDGRID_API_KEY defined as an environment variable
php test.php
Email received with a status code of 202.
I hope this helps.
With Best Regards,
Elmer
Thank you Elmer.
I have finally succeeded in sending emails in V3. I guess the SDK i had downloaded was not up to snuff.
The latest, you suggested, worked perfectly.
My next move was to modify it to send an email to multiple recipients, personalized by recipients.
Now that I have the right SDK i was able to create that without an issue:)
I have added a comment to #318 with the example below which I hope others find useful.