简体   繁体   中英

HTML inside PHP is shown as plain text in email

I'm trying to put html into php for emailing.The first time I tried directly entering the html into the variable (php double quotes and html in single quotes) but that resulted in an internal error. Then I used the <<< function and pasted the html insided (proper use of indentation). Now when I receive the email, i get the html file returned in plain text. How do I go from here?

    $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;

if you're using plain php:

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

you need to add this to the headers:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM