public function addEmbeddedBlobAttachment($content, $filename, $mimeType = null, $contentId = null, array $options = [])
{
if ($mimeType === null) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = $this->_getMimeByExtension($ext);
}
$filename = pathinfo($filename, PATHINFO_FILENAME) . '_' . md5($content) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
if ($contentId === null && ($cid = $this->_isEmbeddedBlobAttachment($content, $filename))) {
return $cid;
}
$options['data'] = $content;
$options['mimetype'] = $mimeType;
$options['contentId'] = $contentId ? $contentId : str_replace('-', '', Text::uuid()) . '@' . $this->_domain;
$file = [$filename => $options];
$res = $this->addAttachments($file);
if ($contentId === null) {
return $options['contentId'];
}
return $res;
}