Tools\Mailer\Email::addEmbeddedAttachment PHP Method

addEmbeddedAttachment() public method

Options: - mimetype - contentDisposition
public addEmbeddedAttachment ( string $file, string | null $name = null, string | null $contentId = null, array $options = [] ) : string | $this
$file string Absolute path
$name string | null (optional)
$contentId string | null (optional)
$options array Options
return string | $this CID or $this
    public function addEmbeddedAttachment($file, $name = null, $contentId = null, array $options = [])
    {
        if (empty($name)) {
            $name = basename($file);
        }
        $name = pathinfo($name, PATHINFO_FILENAME) . '_' . md5($file) . '.' . pathinfo($name, PATHINFO_EXTENSION);
        if ($contentId === null && ($cid = $this->_isEmbeddedAttachment($file, $name))) {
            return $cid;
        }
        $options['file'] = $file;
        if (empty($options['mimetype'])) {
            $options['mimetype'] = $this->_getMime($file);
        }
        $options['contentId'] = $contentId ? $contentId : str_replace('-', '', Text::uuid()) . '@' . $this->_domain;
        $file = [$name => $options];
        $res = $this->addAttachments($file);
        if ($contentId === null) {
            return $options['contentId'];
        }
        return $res;
    }