views:

708

answers:

4

I want to format content of the mail to show the content in different line. here is my message contetn. bu the \n and \r is not working in this case. it just shows all the content in one line.

$message = 'Thank you for using . We really appreciate your business.'."\r\n".'If you are making your payment by mail, please make the check out to "blah blah" and send it to:'."\n".'blah blah '."\n".'blah blah'."\n".'San Gabriel, CA 91776'."\n".'Please see the attached invoice in PDF format for easy saving & printing purposes.';

$attachment = chunk_split(base64_encode($pdfdoc));
$headers = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/pdf; name=\"".$filename."\"".$eol;
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";
mail($_POST['add6'],$subject, $message, $headers);

how can i do that?

A: 

For \n to work it needs to be double quotes, not single. "\n" is the right thing, '\n' is wrong and will not work.

Per Östlund
i have it in double quotes .seem my code
Jasim
take a look at his post he is already using double quotes...
RageZ
My bad. Missed that.
Per Östlund
+4  A: 

You're telling the email client the message is HTML, so the CR LF combination will be treated like any other whitespace.

To fix this, change the content type to show you are sending a plain text email

$headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"".$eol;

Alternatively, turn your message into an HTML message - an easy way to do that in your case would be to run it through nl2br to turn the newlines into <br> tags

Paul Dixon
+1 - Apologies for my edit, thought it was a typo. Sorry!
Dominic Rodger
Actually - are you sure it's not? Can't find any reference to `text/plaint`. Am I missing something?
Dominic Rodger
Content-Type: text/plain; no ?
RageZ
Yes, that was a mistake
Paul Dixon
+3  A: 

Yep you've got Content-Type: text/html, so the CR LF is being treated like whitespace. Either send it as Content-Type: text/plain or call nl2br on your contents.

Dominic Rodger
+1  A: 

Your content type is HTML so you should use br or p tags instead of line feeds

RageZ