2011-12-10 41 views
1

我想发送的通讯,但是当我输入的文本,如:双引号

2nd year, 3rd Special Edition “A Tribute” of 7sisters.in has been released. 
Dear Sir/Madam, 

Welcome to "7sisters.in". 

输出是:

2nd year, 3rd Special Edition “A Tribute†of 7sisters.in has been released. 
Dear Sir/Madam, 

Welcome to "7sisters.in".` 

我跟着这里的答案:

Correctly encode characters in a PHP mail form ("I'm" turns to be "I\'m")

我的PHP代码:

$to = $allEmails[$i]; 
$subject = $sub; 
$message = $msg; 
//$message .= '<p>To unsubscribe , click here <a href="http://www.7sisters.in/index.php?menu=unsubscribe&email='.$to.'">Unsubscribe</a></p>'; 
$message .= '<br />To unsubscribe , click here '; 
$message .= "http://www.7sisters.in/index.php?menu=unsubscribe&email=".$to; 
$message = stripcslashes($message); 


$from = $from_mail; 
//$headers = "From:" . $from; 

$headers = "From:" . $from . "\r\n" . 
       "Reply-To:" . $from . "\r\n" . 
       "X-Mailer: PHP/" . phpversion(); 
$headers .= 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";   

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

使用邮件正常时如何应对双引号()?

+0

刚刚删除stripcslashes并试试,让我们看看 – Bharanikumar

+1

将'iso-8859-1'更改为'UTF-8',你应该没问题。 – zneak

+0

我不需要这些“X-Mailer:PHP /”。 phpversion();和所有,但不知道 – Bharanikumar

回答

4

您有一个编码问题:您的字符串是UTF-8,但是您的内容类型标题声明charset为iso-8859-1。

如果要发送ISO-8859-1中的邮件,请使用utf8_decode将其转换。

+0

现在它像'第二年,第三次特别版?'?致敬? 7sisters.in已经发布。 尊敬的先生/女士, 欢迎来到“7sisters.in”.'。我改变了'$ headers。='Content-type:text/html; charset = iso-8859-1'。 “\ r \ n”;'到'$ headers。='Content-type:text/html; charset = iso-8859-1'。 “\ r \ n”;' – Nitish

+0

Wih utf8_decode?你是如何改变字符集的(你的评论不包含两行之间的任何区别)。 –

+0

对不起......应该是'$ headers。='Content-type:text/html; UTF-8'。为 “\ r \ n” 个; \t' – Nitish