2010-05-03 87 views
4

我正在尝试使用codeigniter发送一封电子邮件,并希望邮件跨越多行。为什么换行符没有被转换为换行符?

$address = $this->input->post('email'); 
$subject = 'Please complete your registration'; 
$message = 'Thanks for registering! \n To complete your registration, please click on (or copy and paste in your browser) the following link: ' . base_url(). "users/confirmRegistration/" . $confirmation_code; //note the '\n' after thanks for registering 

$this->load->library('email'); 
    $this->email->from('[email protected]', 'myname'); 
    $this->email->to($address); 
    $this->email->subject($subject); 
    $this->email->message($message);  
    $this->email->send(); 

我希望邮件与“感谢您的注册”后是一个换行符到达,而是我得到

感谢您的注册! N到完成注册(等等...)

我已经试过\ r \ n但结果几乎是一样的:

感谢您的注册!完成(等等)。这就像应用了striplash功能..

任何想法?

+0

你刚刚尝试过
? – 2010-05-03 21:10:11

回答

17

PHP不会像单引号内的\n那样分析转义序列。

您需要将您的消息字符串用双引号引起来。

+1

快速简洁! +1 – Patrick 2010-05-03 21:31:28

-1

您需要以此格式输入正文。 它工作正常。 Rahul

$ body ='Dear'。 $ row-> fname。 ''。 $ row-> lname。 ','。 '

'。 “您的帐户已暂时停用。” 。 '

'。 '我们的调解人关系团队将尽快与您联系。“ 。 '

'。 '您也可以通过[email protected]与我们取得联系'。 '

'。 '温暖的问候, ' 。 '

'。 ' 团队';

+0

注意:在每个符号之间应该有一个新行.. – 2012-05-01 04:16:49