我正在使用 mailgun 并希望将图像添加到我的时事通讯中。 现在我这样做了:
$mg->sendMessage($domain, array('from' => 'developer@mijnprojectgroep.eu',
'to' => 'developer@mijnprojectgroep.eu',
'subject' => 'Developers Mail Test MijnProjectgroep batch #1',
'text' => 'Hallo %recipient_fname%,
'html' => '<html>
<img style="display:block;" class="img1" src="cid:header-clip.png" width="600" height="64" />
</html>',
array('inline' => '@.././images/newsletter/header-clip.png'),
'o:tracking-opens' => 'yes'));
但是当我收到时事通讯时没有加载图像。 带有上述脚本的文档位于:
根 -->/MailGun/
图片位于:
根 -->/images/newsletter/
也试过:@../../images/newsletter/header-clip.png
文档在这里:
http://documentation.mailgun.com/user_manual.html?highlight=html#sending-via-api
我做错了什么?
最佳答案
你没有做错。实际上 API 文档中存在问题。
您需要在内联图像路径中使用数组而不是字符串路径。它将解决问题。您可以这样添加:
$mg->sendMessage($domain, array('from' => 'developer@mijnprojectgroep.eu',
'to' => 'developer@mijnprojectgroep.eu',
'subject' => 'Developers Mail Test MijnProjectgroep batch #1',
'text' => 'Hallo %recipient_fname%,
'html' => '<html><img style="display:block;" class="img1" src="cid:header-clip.png" width="600" height="64" /></html>',
array('inline' => array('@.././images/newsletter/header-clip.png')
),
'o:tracking-opens' => 'yes'));
请检查这一行:
array('inline' => array('@.././images/newsletter/header-clip.png')
关于php - Mailgun 内联图像,它是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21990031/