2013-04-26 39 views
0

我想通过SMTP使用XpertMailer 4发送电子邮件。它运行良好,除非我的邮件客户端中显示为?的特殊字符(重音字母)。XpertMailer(XPM4)SMTP和字符集

我认为这与charset有关,我不知道如何用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); 

我已经试过包装使用ENT_QUOTEShtmlspecialchars文字和两个ISO-8859-1UTF-8字符集,但结果总是相同的:

Confirma??o de Pedido 

任何帮助将不胜感激!


更新: OK,所以我想通了如何设置编码和更新上面我的代码。不管如果我将编码设置为ISO-8859-1UTF-8 ...

+0

在标题中,还是在无处不在?在标题中,您需要使用RFC2047编码;如果这个图书馆没有照顾到你,也许你应该切换到那个。 – tripleee 2013-04-26 21:04:53

+0

谢谢@tripleee。我想到了。见下文。 – 2013-04-26 21:36:17

回答

0

好吧,我想通了。

似乎XPM4 documentation需要更新(或至少要更清楚)。下面是这样说的:

MIME :: array message (string content [, string type [, string name [, string charset [, string encoding [, string disposition [, string id [, integer line_length [, string line_end ]]]]]]]]) 

注意有一个参数name和参数charset。我同时设置为ISO-8859-1,它工作。