Reputation:
If I fopen/fread a text file, then send the content in an email, the newlines in the text file do not appear in the email when it arrives.
For example, the text...
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Sed leo erat,
rutrum posuere justo.
... arrives in the email inbox as:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed leo erat, rutrum posuere justo.
I'm using this PHP code:
$fh = fopen($email_file,'r');
$message = fread($fh,filesize($email_file));
fclose($fh);
mail("[email protected]",$subject,$message,$headers);
//Assume each variable is declared and defined.
What am I missing?
Edit: I needed to change the header Content-Type from HTML for the text version. Thanks to Yzmir and Footie. Their questions / comments led me to the correct answer.
Upvotes: 0
Views: 324
Reputation: 422
Try replacing the new lines with <br/>
and let me know if this solves it.
If you can't do it for your files, do it in your code using:
$message = nl2br($message);
Upvotes: 1