sendgrid-php: Response status code 0
Issue Summary
I’m trying to execute this test script and it is always returning a zero error code status. No log, no more information about how to trace it. What can I do?
<?php
// If you are using Composer
require "<MY_PATH>/vendor/autoload.php";
$from = new SendGrid\Email(null, "<MY_FROM>@<EMAIL>");
$subject = "Hello World from the SendGrid PHP Library!";
$to = new SendGrid\Email(null, "<MY_TO>@<EMAIL>");
$content = new SendGrid\Content("text/plain", "Hello, Email!");
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$sg = new \SendGrid("<MY_API_KEY>");
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode() . PHP_EOL;
echo $response->body() . PHP_EOL;
echo implode(', ', $response->headers()) . PHP_EOL;
Steps to Reproduce
- git clone git@github.com:sendgrid/sendgrid-php.git
- write this test PHP script and replace my custom values
- execute test PHP script
Technical details:
- sendgrid-php Version: master (latest commit: [46f85e6])
- PHP Version: 7.0.8 (cli) (built: Jun 26 2016 12:30:44)
- SO: OSX 10.11
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 29 (10 by maintainers)
Hi @sadranyi
Are you running a Windows PHP distribution? If so read this article on how to fix it. Have a nice evening!
Thank @thinkingserious I have changed to use python, and sent +20k mails successfully. Therefore, I won’t use php again.
Had the same issue and just needed to download the latest cacert.pem file and making sure the php.ini file referenced it properly.
@thinkingserious I’ve just tried to execute “Hello, World!” example with my API Key and it works perfectly.
Same machine, same environment and same API key. So maybe, I need to check php-curl extension version, compile config params…?
Now is working… thanks for you answer. I don’t understand why now is working, but thanks again.