开发者

PHP Mail function shows messages as plain text in inbox

开发者 https://www.devze.com 2023-01-06 18:13 出处:网络
I am try to send a mail from my php application.Mail send successfully but plain text email which contains html tags.is there any solution for it.Please help me.My message is as follows

I am try to send a mail from my php application.Mail send successfully but plain text email which contains html tags.is there any solution for it.Please help me.My message is as follows

 $message = '
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml">
                        <head>
                            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                                <title>Gaishan</title>
                        </head>
                        <body>
                            <table width="750" border="0" cellspacing="0" cellpadding="0" style="background-color:#043c58; padding:15px;">
                            <tr>
   开发者_运维百科                             <td style="padding-bottom:10px;"><a href="#"><img src="http://www.toobler.com/staging/gaishan/index.php/users/ec/1/logo_mail.jpg"; border="0" /></a></td>
                            </tr>
                            <tr>
                                <td colspan="2" style="background-color:#fff; padding:10px 30px;"><h1 style="font-family:Arial, Helvetica, sans-serif; font-size:26px; font-weight:bold; color:#111;">testmail</h1>
                                  <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:normal; color:#555; line-height:22px;">http://www.toobler.com/</p>
                                      <a href="http://www.toobler.com/" style="font-family:Arial, Helvetica, sans-serif; color:#7ea515; text-decoration:underline;">http://www.toobler.com/staging/gaishan/index.php/users/ec/1/'.time().'</a>
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:normal; color:#4a483f; line-height:22px;">Demo textDemo textDemo textDemo text</p>
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:normal; color:#4a483f; line-height:22px;">Demo textDemo textDemo textDemo textDemo text</p>
                                        <br />
                                        <p style="font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:normal; color:#4a483f; line-height:22px;">Demo textDemo textDemo text<br />
                                        Demo textDemo textDemo text Demo textDemo text
                                        </p>
                                </td>
                            </tr>
                        </table>
                    </body>
                </html>
                ';


Are you also setting the headers to indicate that the email is supposed to be HTML? If you don't, it will always just be plain text.

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

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


You must set: Content-type: text/html; in the header of the mail.


$headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to,$subject,$message,$headers);

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号