我一直试图收到邮件发送HTML电子邮件,但似乎每当我更改标题时
$ message。="内容类型:text / plain;字符集= ISO-8859-1 \ r \ n&#34 ;;到
$ message。="内容类型:text / html;字符集= ISO-8859-1 \ r \ n&#34 ;;
电子邮件没有到达。当使用text / plain时,我会收到电子邮件但是html没有呈现,换句话说我收到的是代码而不是格式化的html。更改为text / html,根本不收到电子邮件。我尝试过使用UTF-8但似乎无法在数小时的搜索后解决它。任何帮助将不胜感激。
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $emessage) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($file);
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$message = "--".$uid."\r\n";
$message .= "Content-type:text/plain; charset=iso-8859-1\r\n";
//$message .= "Content-Type: text/html; charset=\"UTF-8\""."\r\n";
//$message .= "Content-type:text/html; charset=UTF-8\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$message .= $emessage."\r\n\r\n";
$message .= "--".$uid."\r\n";
$message .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
$message .= $content."\r\n\r\n";
$message .= "--".$uid."--";
return mail($mailto, $subject, $message, $header);
}