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?
PHP doesn't parse escape sequences like \n
inside single quotes.
You need to enclose your message string in double-quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With