php - 内嵌多张图片 Mailgun API Batch

标签 php laravel inline mailgun

我正在尝试通过 Mailgun 的内联 API 参数传递多个图像。我对只有一张图片没问题,但是当我尝试使用多张图片时(如下面的代码所示),电子邮件中只显示数组中的最后一张图片。

$template = View::make('emails.template')->render();
$result = $mgClient->sendMessage($domain, array(
  'from'                =>  $sender,
  'to'                  =>  implode(',',$emailAddresses),
  'subject'             =>  '%recipient.subject%',
  'text'                =>  $messageText,
  'recipient-variables' =>  json_encode($credentials),
  'html'                =>  $template
), array(
  'inline'              =>  array(
    'path/to/image1.png',
    'path/to/image2.png',
    'path/to/image3.png',
    'path/to/image4.png')
));

上面的代码就好像数组中的最后一个元素是唯一的元素一样。

已找到使用 Mailgun 发送内联图像的文档 here据说here “您可以发布多个内联值”,这意味着我肯定做错了什么。

最佳答案

试试这个:

$result = $mgClient->sendMessage($domain, array(
  'from'                =>  $sender,
  'to'                  =>  implode(',',$emailAddresses),
  'subject'             =>  '%recipient.subject%',
  'text'                =>  $messageText,
  'recipient-variables' =>  json_encode($credentials),
  'html'                =>  $template
), array(
  'inline'              =>  array(
    array('path/to/image1.png'),
    array('path/to/image2.png'),
    array('path/to/image3.png'),
    array('path/to/image4.png')
)));

基本上将每个图像路径包装在一个数组中。

还有$template的内容是什么?

关于php - 内嵌多张图片 Mailgun API Batch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38757687/

相关文章:

c++ - 内联说明符与类成员一起使用时 undefined reference

使用 IN() 子句的 PHP/MYSQL 更新

php - PHP 5.3 中++ 运算符的奇怪行为

Laravel 自定义认证用户字段

php - Laravel 获取文件内容

compilation - 强制函数在 Clang/LLVM 中内联

php - PDO、mysql、utf8(阿拉伯文本)在 php 中不显示

php - SQLSTATE[42S02] : Base table or view not found: 1146 Table 'laravel_abonamenty2.currencies' doesn't exist

php - PHPUnit 的 GitHub 操作失败

javascript - 为什么带有函数名称的内联事件不能在 div 上工作?