【问题标题】:SendGrid email template style not applyingSendGrid 电子邮件模板样式不适用
【发布时间】:2017-03-29 08:50:07
【问题描述】:

我正在使用 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();

?>

希望有人能帮助我 谢谢

【问题讨论】:

    标签: php sendgrid sendgrid-templates


    【解决方案1】:

    解决了!只是改变 $content = new SendGrid\Content("text/plain", "hello");$content = new SendGrid\Content("text/html", "hello");

    【讨论】:

      猜你喜欢
      • 2012-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多