【问题标题】:PHP mail function outlook UTF8PHP邮件功能outlook UTF8
【发布时间】:2015-02-08 08:58:30
【问题描述】:

我的脚本:

$message = "
<html>
<head>
  <title>Birthday Reminders for August</title>
  <style>td,tr{border:solid 1px black;}</style>
  <meta charset='UTF-8'>
</head>
<body>
  <table>
  <tr><td>სახელი</td><td>{$_POST['firstname']}</td></tr>
  <tr><td>გვარი</td><td>{$_POST['lastname']}</td></tr>
  <tr><td>დაბადების თარიღი</td><td>{$_POST['birthday']}</td></tr>
  <tr><td>მოქალაქეობა</td><td>{$_POST['cityzen']}</td></tr>
  <tr><td>პირადი ნომერი</td><td>{$_POST['id_number']}</td></tr>
  </table>
</body>
</html>
";

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

// Additional headers
$headers .= 'To: Mary <aaa.wwww@gmail.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\n";

// Mail it
mail($to, $subject, $message, $headers);

我已经在 gmail.com、yahoo.com、outlook.com 上对其进行了测试,一切正常。

但是在 MS Outlook 中它有 UTF-8 的问题。

【问题讨论】:

    标签: php email utf-8 outlook


    【解决方案1】:

    尝试使用:

    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
    

    【讨论】:

    • 还是同样的问题
    • 感谢 $headers .= 'Content-type: text/html;字符集=utf-8' 。 "\r\n";我是这样写的,而且效果很好
    • @PiraTa 是的。你没有注意到,我添加了这个词:“charset="
    • 我注意到了,但你没有注意到,我添加了字符:"-" UTF-8 :D
    • @PiraTa 谢谢。我更新了答案。编码的名字真的是 utf-8 :D。
    【解决方案2】:

    尝试添加

    header("Content-type:text/html;charset=utf-8");
    

    到您的 php 文件的顶部。另外您使用的是哪个版本的 Outlook?

    【讨论】:

      猜你喜欢
      • 2012-02-27
      • 1970-01-01
      • 2017-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多