Please excuse my php but, Im using Swiftmailer to send emails from a clients website. They\'ve requested to add an image or two as a signature etc and so looking at the swiftmai
None of the answers really worked for me. I had to include inline images, using CID. What I had to do, to make it work:
$attachment = Swift_Image::newInstance($data, $filename, $mimeType)
->setDisposition('inline');
$cid = $message->embed($attachment); // Generates "cid:something"
Important part is using Swift_Image class. Then the image in html should be:
I think this solution works without doing something hacky with swiftmailer (ver. 5.4.2). It is exactly how the documentation says.
Remember to test multiple email clients (gmail, thunderbird, apple mail, web clients...) if the inline images work. For example using Swift_Attachment, inline images showed in gmail, but not in some web clients. Using Swift_Image, it worked everywhere.