雅虎的邮件格式不正确

时间:2016-04-28 04:56:10

标签: php email

当用户注册或点击忘记密码邮件时发送。它在gmail和其他帐户中看起来很好,但它在雅虎以html格式显示。

代码

   $embody="<p>Dear ".$data['name']." </p>
                <p> Thank you for registering with JCA Associates.  Please log into your account to complete your candidate profile and upload your CV </p><br/>
                <p> JCA Associates</p>
                <p> <img src='".$_SERVER['HTTP_HOST']."/themes/images/logo.png' width='100' height='60'></p>";
                //} else {
                //  $embody="<p>Dear ".$data['name']." </p><p> Thank you for registration with us!</p><p> Best regards,<br/> JCA Team</p>";
                //}
                $message  = '<html dir="ltr" lang="en">' . "\n";
                $message .= '  <head>' . "\n";
                $message .= '    <title>Welcome to JCA Associates</title>' . "\n";
                $message .= '    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
                $message .= '  </head>' . "\n";
                $message .= '  <body><p> ' . html_entity_decode($embody, ENT_QUOTES, 'UTF-8') . '</body>' . "\n";
                $message .= '</html>' . "\n";

在雅虎显示如下。 http://screencast.com/t/wDWixSBI

2 个答案:

答案 0 :(得分:2)

我猜你还没有将HTML标题添加到触发电子邮件调用的函数中。如果您正在使用mail,请添加以下标题:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

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

$subject$to$headers具有适当的值。

答案 1 :(得分:0)

尝试在电子邮件代码中添加以下内容,它就像魅力一样。

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8 \n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP/"."MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html\n";
mail("$sendto","$subject","$embody","$headers","$from");