Path: csiph.com!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: New line character not working in foreach loop Date: Sun, 29 Jan 2017 12:37:24 +0100 Lines: 24 Message-ID: References: <421a78ff-7a42-4c0a-ba17-816d5d02a285@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net zGUAxQf1Fg4SQOtQyHKbEg3lVhB07JyffHiXhK5eZ6sXCg4K5P Cancel-Lock: sha1:XjupkY7zVxjQ9yNnqkjM1vFqCgo= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: Xref: csiph.com comp.lang.php:17303 On 01/29/17 11:39, Christoph M. Becker wrote: > On 29.01.2017 at 03:19, wart2ww wrote: > >> The code I have works correctly except the \n newline character is not working. When the email message is sent, the index values are all printed on one line. What have I done wrong? >> >> foreach ($_POST as $key => $value) { >> >> if (isset($fields[$key])) { >> $emailText .= "$fields[$key]: $value\n"; } >> } > > The proper newline character sequence for emails is CRLF, i.e. "\r\n". > While some MTAs have problems with CRLF, others may actually require it. It's not the issue with the MTA as this don't seem to be the mail header which should be have "\r\n", but in the body itself, then it's a lot about the client used, this mail would look like intended in Thunderbird and would still just be one liner in Outlook, no matter if you have "\r\n" or "\n". -- //Aho