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庫文件?