Email CakePHP发送带有照片的电子邮件
我有一个cakePhp项目,我想用cakePhp电子邮件发送带有照片的电子邮件。发送电子邮件是好的,但照片并没有打印在体内。我给完整的图像url。代码示例如下: 我找不到用电子邮件发送图像的正确方法Email CakePHP发送带有照片的电子邮件,email,cakephp,Email,Cakephp,我有一个cakePhp项目,我想用cakePhp电子邮件发送带有照片的电子邮件。发送电子邮件是好的,但照片并没有打印在体内。我给完整的图像url。代码示例如下: 我找不到用电子邮件发送图像的正确方法 <td style="text-align: right;"> <img alt="" width="120" height="120" src="http://localhost/lictors/app/webroot/img/lict/passport_copy.jpg"&
<td style="text-align: right;">
<img alt="" width="120" height="120" src="http://localhost/lictors/app/webroot/img/lict/passport_copy.jpg">
</td>
首先,您必须像这样附加图像:
$email->attachments([
'photo.png' => [
'file' => '/full/some_hash.png',
'mimetype' => 'image/png',
'contentId' => 'my-unique-id'
]
]);
<img src="cid:my-unique-id">
之后,在img src中引用contentId,如下所示:
$email->attachments([
'photo.png' => [
'file' => '/full/some_hash.png',
'mimetype' => 'image/png',
'contentId' => 'my-unique-id'
]
]);
<img src="cid:my-unique-id">
如果我给出我的ip地址,它会起作用吗?我读过。但它不起作用…你是说你在电子邮件上看不到图像?此图像url中包含localhost
,这意味着无法从公共位置看到它。你需要找到一些不在你的localhost
上的url,使用谷歌搜索中的一些图片并尝试一下。谢谢你…我得到了我的解决方案…@inventation,你在电子邮件中找到显示localhost图片的东西了吗?