PHP IMAP Formatting

I have wrote a simple php script which reads an IMAP email account and displays the body of the most recent mail. There is just one problem, it won't keep the new lines properly. It just puts it all on one line.

I use

imap_fetchbody($conn, $latest, "1");

to read the body of the email. How do I keep the original formatting with all the proper line breaks. Much thanks

Upvotes: 2

Views: 1507

Answers (2)

Supriya
Supriya

Reputation: 101

Why don't you try the print_r option which is in built in PHP?

Upvotes: 0

karim79
karim79

Reputation: 342665

Are you outputting to a browser? Try using nl2br. The doc says:

Inserts HTML line breaks before all newlines in a string

Example:

<?php
echo nl2br("foo isn't\n bar");
//output: foo isn't<br /> bar
?>

Upvotes: 4

Related Questions