我正在尝试使用XpertMailer 4通过SMTP
. 它运行良好,除了我?
的邮件客户端中出现特殊字符(重音字母)。
我认为它与字符集有关,我无法弄清楚如何用XPM4
. 我的代码,如下:
// path to 'SMTP.php' file from XPM4 package
require_once '../includes/XPM4-v.0.5/SMTP.php';
// CONFIGURATION ------------------
$fromName = $_nome; // from name
$from = $_email; // from mail address
$toName = $clienteNome; // to name
$to = $email; // to mail address
$subj = 'Confirmação de Pedido'; // mail subject
$text = 'Confirmação de Pedido';
$html = '<p>Confirmação de Pedido</p>';
// CONFIGURATION ------------------
// set text/plain version of message
$msg1 = MIME::message($text, 'text/plain', 'ISO-8859-1');
// set text/html version of message
$msg2 = MIME::message($html, 'text/html', 'ISO-8859-1');
// compose message in MIME format
$mess = MIME::compose($msg1, $msg2);
// standard mail message RFC2822
$body = 'From: '.$fromName.' <'.$from.">\r\n".
'To: '.$toName.' <'.$to.">\r\n".
'Subject: '.$subj."\r\n".
$mess['header']."\r\n\r\n".
$mess['content'];
// get client hostname
$expl = explode('@', $to);
// connect to SMTP server (direct) from MX hosts list
$conn = SMTP::mxconnect($expl[1]) or die(print_r($_RESULT));
// send mail
$sent = SMTP::send($conn, array($to), $body, $from);
// disconnect from SMTP server
SMTP::disconnect($conn);
我尝试将文本包装在htmlspecialchars
using ENT_QUOTES
and bothISO-8859-1
和UTF-8
charsets 中,但结果始终相同:
Confirma??o de Pedido
任何帮助将不胜感激!
更新:好的,所以我想出了如何设置编码并更新了上面的代码。尽管如此,无论我将编码设置为ISO-8859-1
还是UTF-8
......