内联多张图片 Mailgun API 批量
Inline multiple images Mailgun API Batch
我正在尝试通过 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')
));
上面的代码就好像数组中的最后一个元素是唯一的元素一样。
here and it's said here "You can post multiple inline values" 找到了使用 Mailgun 发送内联图像的文档,这意味着我肯定做错了什么。
试试这个:
$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
的内容是什么?
这实际上是最近引入的错误。新的拉取请求已提交给官方 Mailgun PHP SDK,有关详细信息,请参阅 here。
所以回答这个问题:只要根据上述拉取请求更新 SDK,代码就可以正常工作。现在我相应地编辑了 mailgun-php 的本地副本并且它工作正常。非常感谢 Mailgun 上的 Travis Swientek 快速回复。
我正在尝试通过 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')
));
上面的代码就好像数组中的最后一个元素是唯一的元素一样。
here and it's said here "You can post multiple inline values" 找到了使用 Mailgun 发送内联图像的文档,这意味着我肯定做错了什么。
试试这个:
$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
的内容是什么?
这实际上是最近引入的错误。新的拉取请求已提交给官方 Mailgun PHP SDK,有关详细信息,请参阅 here。
所以回答这个问题:只要根据上述拉取请求更新 SDK,代码就可以正常工作。现在我相应地编辑了 mailgun-php 的本地副本并且它工作正常。非常感谢 Mailgun 上的 Travis Swientek 快速回复。