Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Inline images not displayed in Thunderbird

I want to send a mail trough PHP with inline/embedded images (aka cid). The mail is succesfully sended and received correctly in Gmail. However, in Thunderbird (latest version for windows) the inline/embedded image is not displayed.

I followed the information given in this thread but it still doesn't work. So the inline/embedded image is displayed in Gmail but not in Thunderbird. Does somebody knows the problem here?

To: [email protected]
Subject: Test
From: [email protected] <noreply>
MIME-Version: 1.0
Content-Type: multipart/related; boundary="52cd9ebf4fb8c9b0547e93b82b3f3f6b"

--52cd9ebf4fb8c9b0547e93b82b3f3f6b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Test mail</title>
    </head>
    <body>
        <img src="cid:myImage" alt="This is a embedded image" />
    </body>
</html>

--52cd9ebf4fb8c9b0547e93b82b3f3f6b
Content-Type: image/jpg; name="myImage.jpg"
Content-Transfer-Encoding: base64
Content-ID: <myImage>
Content-Disposition: inline; filename="myImage.jpg"

[base64 encoded string goes here.]

--52cd9ebf4fb8c9b0547e93b82b3f3f6b--
like image 426
Piet Avatar asked Oct 30 '22 17:10

Piet


1 Answers

Mm... In RFC 1521 say that the format of Content-Type header is something like this

The formal grammar for the content-type header field for text is as
follows:

text-type := "text" "/" text-subtype [";" "charset" "=" charset]

text-subtype := "plain" / extension-token

charset := "us-ascii"/ "iso-8859-1"/ "iso-8859-2"/ "iso-8859-3" / "iso-8859-4"/ "iso-8859-5"/ "iso-8859-6"/ "iso-8859-7" / "iso-8859-8" / "iso-8859-9" / extension-token ; case insensitive

I mean the content-type and next the charset But you put

Content-Type: image/jpg; name="myImage.jpg"

so... this maybe can break your image... another suggestion is put your content-ID in lowercase not camel case

regards Emiliano

like image 116
Emiliano Avatar answered Nov 09 '22 13:11

Emiliano