I'm sending an image with an attachment that has to shown as inline image.
I can't find out what's wrong with it. I don't remember this being an issue when I coded the mailer
This is the header of of the image inside the email
--_=_swift_1561449240_8047151997d755eb732462545a29a594_=_
Content-Type: image/png; name=logo.png
Content-Transfer-Encoding: base64
X-Attachment-Id: logo
Content-ID: <logo>
Content-Disposition: inline; filename=logo.png
This is the function that sends an email with attachments
public function send(MailInterface $mail, array $attachments = array())
{
/* @var SwiftMail $swiftMail */
$swiftMail = new SwiftMail(
$mail->getSubject(),
$mail->getBody(),
"text/html"
);
foreach ($attachments as $contentId => $contentPath) {
if (null != $contentPath) {
// prepare content to be send as an attachment
$attachment = SwiftAttachment::fromPath($contentPath);
$attachment->setDisposition("inline");
$attachment->getHeaders()->addTextHeader("Content-ID", "<" . $contentId . ">");
$attachment->getHeaders()->addTextHeader("X-Attachment-Id", $contentId);
// add the attachment to the mail
$swiftMail->embed($attachment);
}
}
/* ... etc ... */
In the template I'm setting the source to the content ID like this:
<img src="cid:<logo>">