2012-07-07 61 views
0

我想使用PHP在主題中使用日語字符發送電子郵件。 我可以通過在發件人中使用jap字符發送,但是當我在主題 中使用它時,電子郵件不會收到。 我該如何解決這個問題。請幫忙。PHP unicode電子郵件

感謝, 絞股藍皁苷

+0

顯示一些代碼... – Daniel 2012-07-07 16:15:30

+1

看似http://stackoverflow.com/questions/4389676/php-email-header-subject-encoding-problem – abelito 2012-07-07 16:16:50

+0

的副本,你試過'函數utf8_encode()',或者'mail_utf8()'? – 2012-07-07 17:41:26

回答

1

(對於 「PHP的unicode電子郵件」)

這裏First result of google的代碼:

$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); 
+4

'=&'已過時。此外,很快,**這**將成爲谷歌第一個結果「php unicode mail」 – 2012-07-07 16:24:55

+0

非常感謝你SinistraD。我會試試這個。 – steven 2012-07-07 16:45:47

+0

@Truth哈哈你是對的,但我只是指出,有時只是谷歌它更容易 – SinistraD 2012-07-07 17:38:42

2

使用PHPMailer的圖書館,我從未有過的UTF8字符的問題,而我使用它。 http://phpmailer.worxware.com/

+0

好的MrRP。非常感謝,我會試試。 – steven 2012-07-07 17:46:26

+0

PHPMailer是一個不錯的提示!最新版本[這裏](http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/PHPMailer%20v5.1/)。 – Stano 2012-07-07 18:24:59