为什么使用SendGrid发送消息会生成0的响应代码?

时间:2016-11-29 19:32:26

标签: php email sendgrid

我正在尝试使用SendGrid和PHP发送电子邮件。这是我的代码:

$from = new SendGrid\Email(null, "noreply@example.com");
$subject = "Password Reset";
$to = new SendGrid\Email(null, $_REQUEST["email"]);
$content = new SendGrid\Content("text/plain", "Your temporary password is " . $newPassword . ".");
$mail = new SendGrid\Mail($from, $subject, $to, $content);

$sg = new \SendGrid($MY_API_KEY);

$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
echo $response->headers();
echo $response->body();

我得到0作为响应代码。这对我来说没有意义,因为根据this page,没有响应代码为0.可能是因为我没有正确加载Sendgrid库文件吗?

1 个答案:

答案 0 :(得分:0)

将php-http-client更新到版本3.5.1后,它现在可以正常工作。我为在StackOverflow上发布此内容而道歉,因为它可能更适合SendGrid GitHub页面。