I have been searching for a way to properly inline images into emails for Sendy (Sendy.co)
. I have only found one way to do it. This method involves using src='cid:imagecidnamejpg'
as an attribute on the <img />
tags that you intend to inline. Example below if I attach a file named imagecidname.jpg
then my cid value in the src tag should be imagecidnamejpg
. As another example: if I use img01.png
, it will strip anything except a-z, 0-9 chars and you will be left img01png
as your corresponding cid value.
Replace $mail->AddAttachment($attachment);
in the /scheduled.php
and /includes/create/send-now.php
with
if (strpos($attachment, '.jpg') !== false || strpos($attachment, '.png') !== false)
{
$cid = preg_replace('/[^a-zA-Z0-9]+/', '', basename($attachment));
$mail->AddEmbeddedImage($attachment, $cid, basename($attachment));
} else {
$mail->AddAttachment($attachment);
}
This code is found just above $mail->send():
in both files. If anyone is bent on propriety, I would only inline (using if logic - not shown) images with the word inline
inside the file name: to ensure only images you want to use for inline, as oppose to attachments. This works inside both Gmail and Outlook.