【发布时间】:2026-01-08 01:25:09
【问题描述】:
我正在尝试使用 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 库文件吗?
【问题讨论】: