【发布时间】:2019-02-21 18:00:11
【问题描述】:
SendGrid Azure 我有一个带有 Ubuntu 的虚拟机,它是我 2 年前在 azure 中创建的,我可以在其中毫无问题地发送电子邮件 throw SendGrind。
现在我用 ubuntu 创建了另一个 VM,我复制了我在另一个服务器中的相同代码,但没有任何效果。我收到 500 错误。 如果我评论下一行,错误就消失了,但我不知道为什么会出现问题:
$response = $sendgrid->send($email);
我不记得我是否需要在服务器中安装一些东西,希望你有一些想法。
require("../sendgrid-php/sendgrid-php.php");
//If not using Composer, uncomment the above line
$email = new \SendGrid\Mail\Mail();
$email->setFrom("xxxxx@gmail.com", "Example User");
$email->setSubject("Sending with SendGrid is Fun");
$email->addTo("xxxxxxx@gmail.com", "Example User");
$email->addContent("text/plain", "and easy to do anywhere, even with PHP");
$email->addContent("text/html", "<strong>and easy to do anywhere, even with PHP</strong>");
$sendgrid = new \SendGrid(getenv('the-key'));
try {
$response = $sendgrid->send($email);
print $response->statusCode(). "\n";
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
【问题讨论】:
标签: php azure ubuntu sendgrid sendgrid-api-v3