【发布时间】:2019-01-13 18:56:40
【问题描述】:
我正在使用类系统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);
【问题讨论】: