Tools\Mailer\Email::_attachFiles PHP Method

_attachFiles() protected method

CUSTOM FIX: blob data support
protected _attachFiles ( string | null $boundary = null ) : array
$boundary string | null Boundary to use. If null, will default to $this->_boundary
return array An array of lines to add to the message
    protected function _attachFiles($boundary = null)
    {
        if ($boundary === null) {
            $boundary = $this->_boundary;
        }
        $msg = [];
        foreach ($this->_attachments as $filename => $fileInfo) {
            if (!empty($fileInfo['contentId'])) {
                continue;
            }
            if (!empty($fileInfo['data'])) {
                $data = $fileInfo['data'];
                $data = chunk_split(base64_encode($data));
            } elseif (!empty($fileInfo['file'])) {
                $data = $this->_readFile($fileInfo['file']);
            } else {
                continue;
            }
            $msg[] = '--' . $boundary;
            $msg[] = 'Content-Type: ' . $fileInfo['mimetype'];
            $msg[] = 'Content-Transfer-Encoding: base64';
            if (!isset($fileInfo['contentDisposition']) || $fileInfo['contentDisposition']) {
                $msg[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
            }
            $msg[] = '';
            $msg[] = $data;
            $msg[] = '';
        }
        return $msg;
    }