早上好,我的 php 页面出现问题,该页面使用 PhpMailer 发送邮件,因为我输入的所有内容在发送到外部应用程序时都带有重音字母,该应用程序使用 Internet Explorer,因为它很旧,下载时没有重音字符;我想这是一个编码问题,为此我尝试做一些我在下面放置的测试:
$today = date("F j, Y, g:i a");
require'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer(true);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Host = "####";
$mail->Username = "####";
$mail->Password = "####";
$mail->SMTPSecure = 'ssl';
$mail->Port = ####;
$mail->From = "####";
$mail->FromName = '';
$mail->charSet = "multipart/alternative";
$mail->AddAddress("####");
$mail->Subject = utf8_decode($oggetto);
$mail->Body = utf8_decode($messaggio);
下面是要发送到需要特殊标签的外部应用程序的消息:
$messaggio = '<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-15">'
. '<!--MF@[WEB]--><strong>ORDINE</strong> num. <!--MF$[NUM]-->' . $numero_ordine . '<!--MF&[NUM]--> del <!--MF$[DAT]-->' . $data . '<!--MF&[DAT]--><br/>'
. '<hr/><br/>'
. 'Azienda: <!--MF$[SOC]-->' . $UserSoc . '<!--MF&[SOC]--> ' . $strSocCts . '<br />'
. $strSdi
. $strInd . '<br/>'
. $strPiv . '<br/>'
. $strCRS . '<br/>'
. $strTel . '<br />'
. $strEma . '<br />'
. '<br />'
. 'Dati recapito:<br />'
. '<hr/>'
. $strRecSoc . '<br/>'
. $strRecInd . $strRecTel . $strRecEma
. '<br /><br />'
. $prodott
. '<hr/>'
. 'Subtotale materiale: ' . fix($total) . ' euro + Trasporto: ' . $trasporto . ' euro <br />'
. $ivatotale . $sconto . $pagamento
. 'Vettore: ' . $vettore . '<br />'
. '<hr>'
. $totaletotale
. $annotazioni
. 'Note : <br/><hr>'
. $UserNec . '<br/><br/>';
作为编码测试,我测试了这些,但我只得到没有重音或“奇怪”字符的字符。
/**
* The character set of the message.
* @type string
*/
public $CharSet = 'UTF-8';
/**
* The MIME Content-type of the message.
* @type string
*/
public $ContentType = 'text/plain';
试图输入 charset = ISO-8859-1 或 UTF8 但没有结果。
我只是不明白我错在哪里。提前致谢。