private function attachAll() : string
{
$mime = [];
foreach ($this->email->attachments as $attachment) {
$encoding = !empty($attachment->encoding) ? $attachment->encoding : Encoding::BASE64;
$name = $this->changeCharset($this->clearHeaderValue($attachment->name));
$mime[] = '--' . $this->boundary[1] . self::LINE_END;
$mime[] = 'Content-Type: ' . $this->clearHeaderValue($attachment->mimeType) . ';' . self::LINE_END;
$mime[] = ' name="' . $this->encodeHeader($name) . '"' . self::LINE_END;
$mime[] = 'Content-Transfer-Encoding: ' . $encoding . self::LINE_END;
if ($attachment->isInline()) {
$mime[] = 'Content-ID: <' . $this->clearHeaderValue($attachment->cid) . '>' . self::LINE_END;
}
$mime[] = 'Content-Disposition: ' . $attachment->disposition . ';' . self::LINE_END;
$mime[] = ' filename="' . $this->encodeHeader($name) . '"' . self::LINE_END . self::LINE_END;
// Just fix line endings in case of encoded attachments, encode otherwise
$mime[] = !empty($attachment->encoding) ? \Jyxo\StringUtil::fixLineEnding($attachment->content, self::LINE_END) : $this->encodeString($attachment->content, $encoding);
$mime[] = self::LINE_END . self::LINE_END;
}
$mime[] = '--' . $this->boundary[1] . '--' . self::LINE_END;
return implode('', $mime);
}