我将此代码用于用户忘记密码的电子邮件。但它并没有给我实际的输出。提交表单后,它会带来阿拉伯语结果和html标签。我的邮件中也收到了html标签代码:
//......mail
$to = $email;
$subject = 'Forgot Password';
$message = '
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>هل نسيت كلمة المرور</title>
</head>
<body dir="rtl">
</p>
<p align="right">عزيزي،</p>
<p align="right">لقد تلقينا طلبا من جانبكم لاستعادة كلمة المرور. </p>
<p align="right">يتم إلحاق بيانات الدخول الخاصة بك أدناه: </p>
<p align="right">البريد الإلكتروني: <strong>'.$to.'</strong></p>
<p align="right">
كلمة المرور:<strong> '.$password.'</strong><br/>
إلى تسجيل الدخول الرجاء اضغط هنا أو نسخ www.cb.gminns.com/login.php الرابط ولصقه في شريط عنوان المتصفح الخاص بك.
</p>
<br>
<p align="right"> Warm Regards,
Contributors Den Team </p>
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "'r'n";
$headers .= "MIME-Version: 1.0'r'nContent-type: text/plain; charset=UTF-8'r'n";
$headers .= "Content-type: text/html; charset=utf-8" . "'r'n";
$headers .= 'From: Contributors Den <noreply@test.com>' . "'r'n";
mail($to, $subject, $message, $headers);
header('location:forgot_password.php?msg=sent');
在我的雅虎邮件网络版本中,输出是这样的
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>هل نسيت كلمة المرور</title>
</head>
<body dir="rtl">
</p>
<p align="right">عزيزي،</p>
<p align="right">لقد تلقينا طلبا من جانبكم لاستعادة كلمة المرور. </p>
<p align="right">يتم إلحاق بيانات الدخول الخاصة بك أدناه: </p>
<p align="right">البريد الإلكتروني: <strong>admintest@yahoo.com</strong></p>
<p align="right">
كلمة المرور:<strong> 123</strong><br/>
إلى تسجيل الدخول الرجاء اضغط هنا أو نسخ الرابط ولصقه في شريط عنوان المتصفح الخاص بك.
</p>
</body>
</html>
这是我收到的最后一封电子邮件,它带来了html编码
问题如下:
$headers .= "MIME-Version: 1.0'r'nContent-type: text/plain; charset=UTF-8'r'n";
这应该是
$headers .= "MIME-Version: 1.0'r'nContent-type: text/html; charset=UTF-8'r'n";