Embedding Images in Email Using PHPMailer

5 Feb, 2007 | Expert TipsTipsTechVfd

For anyone who has been hunting high and low for a solution to a problem I was having with PHPMailer and embedded images in HTML emails. The problem was that despite me being confident my code to insert the image was right, it was still appearing as an attachment (in Thunderbird at least). It turns out that the problem was the content type declaration, Thunderbird is very strict in its settings for attachments and doesn't like the default application/octet-stream setting if you're attaching images, so you have to make sure to set it correctly for the image you are embedding. I can't take the credit, I found the answer on the sourceforge mailing list, after digging, a lot.

For embedded images (using AddEmbeddedImage) Netscape
and Firefox are sticklers for having the $type set to the specific embedded file type,
otherwise they show it as an attachment. I was using the default value:
"application/octet-stream", which only worked fine for Outlook. Once I changed the $type to
image/jpeg or image/gif, it works for everyone.