我使用SendGrid PHP API发送简报,但是当我使用模板ID时,发送的邮件并不包含CSS&图像。
这是我的代码:
<?php
require("sendgrid-php/sendgrid-php.php");
$from = new SendGrid\Email(null, "contact@projet.com");
$subject = "Hello World from the SendGrid PHP Library!";
$to = new SendGrid\Email(null, "me@icloud.com");
$content = new SendGrid\Content("text/plain", "hello");
$mail = new SendGrid\Mail($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();
?>
希望有人能帮助我 感谢
答案 0 :(得分:2)
解决了!只是改变
$content = new SendGrid\Content("text/plain", "hello");
来
$content = new SendGrid\Content("text/html", "hello");