我正在尝试使用cake php发送电子邮件,这里是代码
<table class="section-table">
<tbody>
<tr><td class="section-topic">Testing</td></tr>
<tr data-ng-repeat="subtopic in main.subtopics">
<td data-ng-click="subtopic.isCollapsed = !subtopic.isCollapsed" class="section-subtopic">{{subtopic.label}}
<div uib-collapse="subtopic.isCollapsed" expanded="main.showContent(subtopic.id)">
<div data-ng-repeat="content in main.contents" class="topic-content">
<div data-ng-bind="content.content"></div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
但它似乎只是添加了一个附件。我能以任何方式附加多个文件吗?
答案 0 :(得分:0)
attachments()方法允许您添加图像路径数组。像这样更改你的源代码
$data = "RSIMT7210;RSIMT7220";
$email = new CakeEmail();
$var = ROOT;
$var = str_replace("api", "", $var);
$attachments = array();
$myArray = explode(';', $data);
foreach($myArray as $sku)
{
$result = $this->Ring->find('first', array('conditions'=>array('sku'=>$sku)));
$ring = $result['Ring'];
$ringItems = explode(' ', $ring['name']);
$styleNumber = $ringItems[0];
$mAttach = $var . "rings/" . "$styleNumber/image/white.jpg";
$attachments[] = $mAttach;
}
$email->attachments($attachments);
答案 1 :(得分:0)
好的主要问题是所有附件都有相同的名称。我必须使用不同的名称才能使其工作。现在我正在使用这个
$attachments[$styleNumber . ".jpg"] = array(
'file' => $mAttach,
'mimetype' => 'image/png',
'contentId' => $styleNumber
);