簡體   English   中英

PHP中的HTML在電子郵件中顯示為純文本

[英]HTML inside PHP is shown as plain text in email

我試圖將html放入php中以便通過電子郵件發送電子郵件。第一次嘗試直接將html輸入變量(php雙引號和html單引號),但這導致內部錯誤。 然后,我使用了<<<函數,並將html粘貼了在內(正確使用了縮進)。 現在,當我收到電子郵件時,我得到了以純文本格式返回的html文件。 我怎么從這里走?

    $mailer->Body = <<<DEMO
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
........
</tbody>
        </table>
    </body>
</html>


DEMO;

如果您使用的是純PHP:

mail($to, $subject, $message, $headers);

您需要將其添加到標題中:

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM