My line breaks are showing up as =20.  What do I need to do?

jvutechnc used Ask the Experts™
My line breaks are showing up as =20.  What do I need to do?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

You need to post the code that is causing this. So we can see where the problem is.
Most Valuable Expert 2011
Top Expert 2016

Might be an encoding problem of some sort I am used to seeing =0A=0D in emails.  IIRC =20 should be a space, not a line break.


Hi, I'm going to paste the output example and code for your review.

Here's an example output of the message body.
test message=20

John Smith=20
Programmer/web developer=20

Acme Inc.=20
705 Griffith St. Suite 300=20
Davidson, CA 28036=20
office 123.444.0219 x246=20
cell 123.1233.9478=20
The code I attached show the script that inserts the email into mysql.
The apache and mysql server is on Windows Server 2003; my colleague was saying something about
Windows and linux handling line breaks differently....
	error_reporting(E_ALL ^ E_NOTICE);

function translate_object($obj){
 return $obj->mailbox.'@'.$obj->host;


/* connect to server */
	$hostname = '{}INBOX';
	$username = 'xxxx';
	$password = 'xxxx';

/* try to connect */
	$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to server: ' . imap_last_error());

/* grab emails */
	$emails = imap_search($inbox,'ALL');

	$headers = imap_headers($inbox);
	$numEmails = sizeof($headers);

	for($i = 1; $i < $numEmails+1; $i++)


$mailHeader = @imap_headerinfo($inbox, $i);

$from = $mailHeader->reply_toaddress;

$subject = ($mailHeader->subject);

$body = (imap_fetchbody($inbox, $i, '1'));

$date = $mailHeader->date;

$rows = "SELECT * FROM requests";
$result = mysql_query($rows);

$query = "INSERT INTO requests (`date`, `from`, `subject`, `message`) VALUES ('".date("DdM H:i")."','$from', '$subject', '".mysql_real_escape_string($body)."')";

$res = mysql_query($query);

/* close the connection */


Open in new window

Most Valuable Expert 2011
Top Expert 2016

For starters change this:
error_reporting(E_ALL ^ E_NOTICE);
... to this:

For PHP end of line characters use the predefined constant PHP_EOL.

Will try to look at it again this evening, ~Ray

$str = str_replace('=20', PHP_EOL, $str);

The above code removed the =20 for me.

Thank you Ray!!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial