2012-04-29 57 views
0

當爲CodeIgniter電子郵件類準備消息時,我似乎做錯了什麼。我有以下代碼:在CodeIgniter電子郵件類中不顯示換行符

$message = "Registration Confirmation and Receipt"; 
$message .= "\r\n"; 
$message .= "Thank you for registering for MAGIC Live. Your credit card receipt and a complete confirmation of your registration is below. Please keep it for your records.\r\n"; 
$message .= "\r\n"; 
$message .= "Credit card: XXXX XXXX XXXX ".$group['last4']; 
$message .= " Exp: ".$group['exp_month']."/".$group['exp_year']."\r\n"; 
$message .= "data"; 
$this->email->message($message); 

只有兩組相鄰的換行符纔會生效。輸出的電子郵件如下所示:

Registration Confirmation and Receipt Thank you for registering for MAGIC Live. Your credit card receipt and a complete confirmation of your registration is below. Please keep it for your records. 

Credit card: XXXX XXXX XXXX 4242 Exp: 3/2015 data 

有什麼想法?

+1

可能使用HTML進行郵件。嘗試用「
」替換「\ r \ n」。 –

+1

或使用'$ this-> email-> message(nl2br($ message));' –

+0

感謝您抽出時間發表評論。 CI默認爲電子郵件的文本。只是爲了踢我配置'mailtype'值設置爲文本,它沒有任何影響。我想我要切換到HTML。謝謝! –

回答

0

檢查電子郵件配置。您可以設置換行符。默認是\ n。

$config['newline'] = "\r\n"