所以我一直在爲此付出很多努力,並最終完成了一些工作。在一些電子郵件客戶端上,這些代碼顯示了正確嵌入的三張圖片,有些將它們附加爲附件,而其他的則不顯示。我做錯了什麼,我該如何解決。將圖像嵌入到HTML郵件中
電子郵件與PHP的mail()
- 函數發送像這樣:mail($_POST['email'],'Signature',$body,$header);
此外,有人拍攝我面前,我知道這是不妥當的編程習慣,但這個腳本是隻有我們有一個本地腳本訪問簡單生成的電子郵件簽名。所以這就是爲什麼它沒有進行任何輸入驗證或清理。
$header = 'From:[email protected]' . "\r\n";
$header .= 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type:multipart/mixed; boundary="B_3504178637_3566343"' . "\r\n";
$body = '> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--B_3504178637_3566343
Content-type: multipart/alternative;
boundary="B_3504178637_3589184"
--B_3504178637_3589184
Content-type: text/plain;
charset="US-ASCII"
Content-transfer-encoding: 7bit
Regards,
details
--B_3504178637_3589184
Content-type: text/html;
charset="US-ASCII"
Content-transfer-encoding: quoted-printable
<table cellpadding="0" cellspacing="0" width="300">
<tr>
<td style="padding-right: 10px; border-bottom: 1px solid rgb(255, 255, 255);">
<img src="cid:E3FFCD1F-2201-4790-81B5-5F4F9B82A413" type="image/png" width="51" style="width:51px">
</td>
<td style="text-align: center; border-bottom: 1px solid rgb(221, 221, 221);">
<span style="color: rgb(31, 130, 197); font-family: Helvetica; font-size: 13px; line-height: 20px;">' . strtoupper($_POST['name']) . '</span><br>
<span style="color: rgb(102, 102, 102); font-family: Helvetica; font-size: 13px;">' . strtoupper($_POST['designation']) . '</span>
</td>
</tr>
<tr>
<td style="padding-right: 10px; border-bottom: 1px solid rgb(255, 255, 255); border-top: 1px solid rgb(255, 255, 255);">
<img src="cid:060EED13-21A7-4FF2-BDCE-D5A87BD2165B" type="image/png" width="51" style="width:51px">
</td>
<td style="text-align: center; border-bottom: 1px solid rgb(221, 221, 221);">
<span style="color: rgb(31, 130, 197); font-family: Helvetica; font-size: 13px; line-height: 20px;">CONTACT ME</span><br>
<span style="color: rgb(102, 102, 102); font-family: Helvetica; font-size: 10px;">T: ' . $_POST['telephone'] . ' | ' . ($_POST['fax'] != "" ? "F: " . $_POST['fax'] : ($_POST['cellphone'] != "" ? "C: " . $_POST['cellphone'] : "F: 086 694 0819")) . '</span>
</td>
</tr>
<tr>
<td style="padding-right: 10px; border-top: 1px solid rgb(255, 255, 255);">
<img src="cid:CA0B3207-4728-46DE-8BC7-72723443E97A" type="image/png" width="51" style="width:51px"></td>
<td style="text-align: center;">
<span style="color: rgb(31, 130, 197); font-family: Helvetica; font-size: 13px; line-height: 20px;">company name</span><br>
<span style="color: rgb(102, 102, 102); font-family: Helvetica; font-size: 10px;"><i>address</i></span>
</td>
</tr>
</table>
--B_3504178637_3589184--
--B_3504178637_3566343
Content-type: image/png; name="E3FFCD1F-2201-4790-81B5-5F4F9B82A413.png"
Content-ID: <E3FFCD1F-2201-4790-81B5-5F4F9B82A413>
Content-disposition: inline;
filename="E3FFCD1F-2201-4790-81B5-5F4F9B82A413.png"
Content-transfer-encoding: base64
//base64 encoded image
--B_3504178637_3566343
Content-type: image/png; name="060EED13-21A7-4FF2-BDCE-D5A87BD2165B.png"
Content-ID: <060EED13-21A7-4FF2-BDCE-D5A87BD2165B>
Content-disposition: inline;
filename="060EED13-21A7-4FF2-BDCE-D5A87BD2165B.png"
Content-transfer-encoding: base64
//base64 encoded image
--B_3504178637_3566343
Content-type: image/png; name="CA0B3207-4728-46DE-8BC7-72723443E97A.png"
Content-ID: <CA0B3207-4728-46DE-8BC7-72723443E97A>
Content-disposition: inline;
filename="CA0B3207-4728-46DE-8BC7-72723443E97A.png"
Content-transfer-encoding: base64
//base64 encoded image
--B_3504178637_3566343--' . "\r\n";