我正在尝试通过 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/