2016-11-29 73 views
2

我正在嘗試使用SendGrid和PHP發送電子郵件。這是我的代碼:爲什麼使用SendGrid發送消息會生成響應代碼0?

$from = new SendGrid\Email(null, "[email protected]"); 
$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庫文件?

回答

0

將php-http-client更新到版本3.5.1後,它現在可以正常工作。我很抱歉在StackOverflow上發佈這個,因爲它可能會更適合SendGrid GitHub頁面。

相關問題