多余的字符出现在电子邮件主题的£在磅符号前

问题描述 投票:0回答:1

我使用的是类系统PHP文件从MySQL数据库发送的HTML电子邮件,一个多余的字符显示在主题标题£英镑符号的前面,但电子邮件的主要内容是罚款。

我已经使用了电子邮件中的UTF字符集试过,但是这打破了实际的电子邮件内容区域,以便所有的邮件不再发送HTML内容,但它确实解决这个主题£英镑符号问题。也试过str_replace函数如果有一种方法,使标题只使用UTF和内容的HTML这将是完美的解决方案的代码了。

邮件主题代码段低于(私人详细内容略)

function
sendTemplateEmail($groupid,$subject,$body,$tipster_code,
$email_image,$tipster_name,$only_active="",


{
        global $conn;

    $errors = "";
    $email_list = array();
    $total_users = 0;
    $group = (is_numeric($groupid)) ? $groupid : 0;

    #die("body = ".$body);

    $body = str_replace("£","£",$body);
    $body = str_replace("Â","",$body);
    $subject = str_replace("Â","",$subject);


 $html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
 $html .= "<html lang='en'>\n";
 $html .= "<head>\n";
 $html .= "<meta http-equiv=\"Content-Type\" content=\"text/html;   charset=iso-8859-1\">\n";
 $html .= "<title>O.com</title>\n";
 $html .= "</head>\n";
 $html .= "<body style='width:800px;' bgcolor=\"#FFFFFF\">\n";

$dw_mail->AddReplyTo("admin@","");
$dw_mail->ReturnPath = "admin@";
$dw_mail->From = $from;
$dw_mail->FromName = $from;
$dw_mail->AddAddress($users['email'],"");
$dw_mail->AddAddress("@hotmail.com","");
$dw_mail->WordWrap = 50;                              // set word wrap
//$dw_mail->AddAttachment(PDF_PATH."app-".$app.".pdf");
$dw_mail->IsHTML(); // send as html
$dw_mail->Subject  =  stripslashes($subject);
$dw_mail->Body = $html;
$dw_mail->AltBody = stripslashes($alt_body);
php utf
1个回答
1
投票

以UTF-8字符£是两个字节encoded:使用ISO-8859-1 C2 A3 C2 A3解码给出:£

所以我想这主题,你从MySQL数据库中获得的价值在UTF-8编码,而$ dw_mail->主题期望在ISO-8859-1编码的值。

使用mb-convert-encoding应该让你从UTF-8到ISO-8859-1的转换。请注意,并非所有的UTF-8字符可以映射到ISO-8859-1,所以你可能会与其他特殊字符的问题。

© www.soinside.com 2019 - 2024. All rights reserved.