tags:

views:

88

answers:

1

Hi all, I'm trying to send an email using codeigniter, and would like the message to span over several lines.

$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();

I would expect the mail to arrive with a line break after "Thanks for registering", but instead i get

Thanks for registering! n To complete your registration (etc etc...)

I've tried with \r\n but the result is almost the same:

Thanks for registering! rn To complete (etc etc). It's like there were a stripslash function applied..

Any ideas?

+2  A: 

PHP doesn't parse escape sequences like \n inside single quotes.

You need to enclose your message string in double-quotes.

zerocrates
quick and concise! +1
Patrick