我通過PHP從包含HTML代碼的變量向郵件功能發送回顯。奇怪的是,這是這個當我嘗試「回顯」html字符串時,如何獲得這些奇怪的字符?
<����}im�
顯示後的字符串..但我不再操縱它了。郵件功能的字符集(附件)與HTML代碼的字符集相同。
我通過PHP從包含HTML代碼的變量向郵件功能發送回顯。奇怪的是,這是這個當我嘗試「回顯」html字符串時,如何獲得這些奇怪的字符?
<����}im�
顯示後的字符串..但我不再操縱它了。郵件功能的字符集(附件)與HTML代碼的字符集相同。
編碼的問題,也許是試圖顯示二進制代碼嗎?
如果歐想顯示HTML
//輸出你要用htmlentities:一個 '報價' 是
<b>大膽</B >呼應
ヶ輛($海峽);
我不知道我理解這一點,但我會檢查對谷歌:) THX – Skuta 2008-11-18 22:08:34
這些字符可能是「垃圾」數據的字符串。根據字符串來自這些字符的位置可能是:HTML頁面之後的套接字中的額外TCP數據,或HTML頁面之後的文件中的額外數據,或者其他人實際將這些字符放入其HTML頁面(可能是其文件被意外損壞,或出於其他原因)。
你可以考慮使用htmlMimeMail類用於處理電子郵件。所以你可以避免討厭的電子郵件內部。
這是我有問題..我使用的代碼來自互聯網來源,$體生成發票,這將電子郵件發送..這些字符在HTML源文件的末尾,但我不明白爲什麼他們在那裏是地獄:(
$to = '[email protected]';
$subject = 'Invoice';
$random_hash = md5(date('r', time()));
$headers = "From: [email protected]\r\nReply-To: [email protected]";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$body=rtrim(chunk_split(base64_encode($body)));
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Text Emailu.
--PHP-alt-<?php echo $random_hash; ?>--
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: text/html; charset="UTF-8"; name="faktura.html"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
<?php echo htmlentities($body); ?>
--PHP-mixed-<?php echo $random_hash; ?>--
<?php
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail($to, $subject, $message, $headers);
我想我們需要更多的細節。你能找到的字節序列產生的無效字符?(查看用十六進制編輯器?) – Artelius 2008-11-18 21:52:35
我相信你會發現在這個良好的信息HTTP ://stackoverflow.com/questions/275411問題 – VonC 2008-11-18 22:13:32