发送网格电子邮件模板样式不适用



我正在使用SendGrid PHP API发送时事通讯,但是当我使用模板ID时,发送的邮件不包含CSS和图像。

这是我的代码:

<?php
require("sendgrid-php/sendgrid-php.php");
$from = new SendGridEmail(null, "contact@projet.com");
$subject = "Hello World from the SendGrid PHP Library!";
$to = new SendGridEmail(null, "me@icloud.com");
$content = new SendGridContent("text/plain", "hello");
$mail = new SendGridMail($from, $subject, $to, $content);
$mail->setTemplateId("727274bc-XXXX-XXXX-XXXX-83a2b53597e5");
$apiKey = 'SG.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$sg = new SendGrid($apiKey);
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
echo $response->headers();
echo $response->body();
?>

希望有人能帮助我谢谢

已解决!只需更改 $content = new SendGridContent("text/plain", "hello");$content = new SendGridContent("text/html", "hello");

最新更新