【问题标题】:PHP unicode emailPHP Unicode 电子邮件
【发布时间】:2012-07-07 18:20:31
【问题描述】:

我想使用 PHP 发送一封主题为日文字符的电子邮件。 我可以在发件人中使用日本字符发送,但是当我在主题中使用它时 电子邮件收不到。 我该如何解决这个问题。请帮忙。

谢谢, 吉普

【问题讨论】:

标签: php


【解决方案1】:

First result of google(用于“php unicode 电子邮件”)

代码如下:

$headers['To'] = $to;
$headers['From'] = $from;
$headers['Content-Type'] = "text/plain; charset=utf-8";
$headers['Content-Transfer-Encoding'] = "8bit";
$b64subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
$headers['Subject'] = $b64subject;

$mail = Mail::factory('sendmail', array('host' => $host, 'port'=>$port));
$retval =  $mail->send($to, $headers, $body);

【讨论】:

  • =& 已过时。此外,很快,this 将成为 google 上“php unicode mail”的第一个结果
  • 非常感谢 SinistraD。我会试试这个。
  • @Truth 哈哈,你是对的,但我只是指出,有时候用谷歌搜索会更容易
【解决方案2】:

使用 PHPmailer 库,我在使用 UTF8 字符时从未遇到过问题。 http://phpmailer.worxware.com/

【讨论】:

  • 好的 MrRP。非常感谢。我会努力的。
  • PHPMailer 是个好技巧!最新版本here.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-12-24
  • 1970-01-01
  • 1970-01-01
  • 2014-12-15
  • 2016-06-07
  • 1970-01-01
  • 2014-08-17
相关资源
最近更新 更多