0

我正在发送 html 消息包含表格

当我在 gmail、hotmail、yahoo 帐户上收到消息时,它工作正常,但在其他客户端(即 Microsoft Outlook)上接收时,它会将其解析为 html 代码!

这是我的电子邮件标题

            'MIME-Version: 1.0' . "\r\n" .
    'Content-Type: text/html;charset= UTF-8' . "\r\n" .
            'From: me <me@client.com>'
4

2 回答 2

0

我总是使用这个功能,它有帮助

  function sendHTMLemail($HTML,$from,$to,$subject,$fromname)
        {
            $headers = "From: ".$fromname." <".$from.">\r\n";
            $headers.= "Reply-To: ".$fromname." <".$from.">\r\n";
            $headers .= "MIME-Version: 1.0\r\n"; 

            $boundary = uniqid("HTMLEMAIL"); 

        // First we be nice and send a non-html version of our email        
            $headers .= "Content-Type: multipart/alternative;".
                        "boundary = $boundary\r\n\r\n"; 
            $headers .= "This is a MIME encoded message.\r\n\r\n"; 
            $headers .= "--$boundary\r\n".
                        "Content-Type: text/plain; charset=ISO-8859-1\r\n".
                        "Content-Transfer-Encoding: base64\r\n\r\n";                    
            $headers .= chunk_split(base64_encode(strip_tags($HTML))); 
            // Now we attach the HTML version
            $headers .= "--$boundary\r\n".
                        "Content-Type: text/html; charset=ISO-8859-1\r\n".
                        "Content-Transfer-Encoding: base64\r\n\r\n";                    
            $headers .= chunk_split(base64_encode($HTML)); 
            // And then send the email ....
            mail($to,$subject,"",$headers);

        }
于 2012-05-16T10:42:19.893 回答
0

我知道这不是您问题的答案,但我建议使用邮件库,它可以让您更轻松地发送邮件,并支持附件、身份验证等功能。
我推荐SwiftMailer效果很好,是简单且有据可查。

于 2012-05-16T14:11:13.900 回答