我在我的 PHP 应用程序中使用 SendGrid 向我的用户发送电子邮件,以便他们可以重置密码。问题是,在 localhost 上一切正常,但是当我将文件传输到服务器时,我打印了以下响应0 Array ( [0] => )
。我在Network上检查时收到的状态代码响应是 200 OK,在 SendGrid 上这意味着Your message is valid, but it is not queued to be delivery 。我不知道为什么会这样,有什么帮助吗?
$email = new SendGrid\Mail\Mail();
$email->setFrom("email@email.com", "Person");
$email->setSubject("Subject");
$email->addTo("email@email.com", "Person");
$email->addContent("text/plain", "This is the email.");
$email->addContent(
"text/html",
'<p>This is the email</p>'
);
$sendgrid = new \SendGrid('myKey');
try {
$response = $sendgrid->send($email);
print($response->statusCode());
} catch (Exception $e) {
echo 'Caught exception: ' . $e->getMessage() . "\n";
}