Welcome Guest, Not a member yet? Register   Sign In
(SOLVED) newline for email message ?
#1

[eluser]fs_xyz[/eluser]
Hi, I'm new here, just first time using CI for some developing.

Probably this will be a stupid question... but how to create a new line for email message ?

Originally message for email will be using this, right ?
$this->email->message();

Well... how to create new line if the message end up with multiple sentences ?

Uhh, for example, the input message is from a form. The fields are username and password.
My current state, since I unable to create new line, is as follow :

username : abcdefpassword : abcdef

I want to make it into :
username : abcdef
password : abcdef

How to create new line ? Sad

Is this have something to do with $this->email->set_newline("\r\n"); ?
If so, how to use it ?
#2

[eluser]Alur[/eluser]
You just need to add the newline character:
Code:
\n
If your are sending HTML formatted email, add:
Code:
<br />
Or you can add both, just to make sure:
Code:
<br />\n

So you could set your message like this:

Code:
$email_message = "User: ".$this->input->post('username')."<br />\n";
$email_message .= "Password: ".$this->input->post('password')."<br />\n";
$this->email->message($email_message);
#3

[eluser]tkyy[/eluser]
as the post above me said you add the unix newline character, "\n" (make sure you use double quotes). you can also change this option in the email library configuration.
#4

[eluser]fs_xyz[/eluser]
o_O.... double quote... now wonder it didn't work in the first place. I used single quote.
Thank you very much.
Is there another "need to use double quote" I have to aware off ?
Or what is actually the difference of using single and double ?
Does it about single quote for variable while double for text only ?
#5

[eluser]bertrand[/eluser]
Just to clarify if anyone fall on this...

Double quotes transforms variables and other things (like \n and \t) while single quote, well, doesn't.

That's the difference!




Theme © iAndrew 2016 - Forum software by © MyBB