2013-04-26 23 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,它工作。