matte Posted February 8, 2012 Share Posted February 8, 2012 This happens from time to time and it really drives me crazy. I cannot get the problem to reproduce, although I have plenty of evidence that it is happening. I have a php page that pulls in some database from mssql formats it in a nice table then send via email to a 3rd party. All of that works great. What happens is in some of the emails the first column will show the table cell information for the next column. See example: Mascaw Mar. 8, 2012 - 6:15 pm Ronnie Johnson Newtown Pike<td width="150"> Mar. 8, 2012 - 6:15 pm Todd Doe Hall of Justice Mar. 8, 2012 - 6:15 pm Carol French I had this problem before with another emailing system and found that wrapping the email to 900 before sending it out fixed it. I wrapped this with $message = wordwrap($message, 900, "\n", true); but it doesn't seem to make a difference. Anyone ran into this before? Any help would be greatly appreciated! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/256668-html-email-showing-code/ Share on other sites More sharing options...
ManiacDan Posted February 8, 2012 Share Posted February 8, 2012 It's probably breaking in the middle of your tag. Insert newlines yourself, don't rely on wordwrap. Quote Link to comment https://forums.phpfreaks.com/topic/256668-html-email-showing-code/#findComment-1315793 Share on other sites More sharing options...
DavidAM Posted February 8, 2012 Share Posted February 8, 2012 $message = wordwrap($message, 900, "\n", true); The "true" parameter forces the break at 900 (in this case). If this parameter is "false" it will find a space to break on. So, it could be breaking in the middle of a tag name or attribute name or value. (whitespace inside a tag is not significant unless it breaks a name or value) The RFC specifies <CRLF> as the line break. Most mail systems probably handle <LF> alone, but there may be some that do not. You might consider wrapping it with "\r\n". When generating HTML for a mail message (or for a web page, for that matter), I always stick in line-feeds at the end of blocks and so forth -- so, after </P>, </TR>, </DIV>, even </TD> if the rows are long), then I wordwrap() to about 70. wordwrap() seems to honor the line-feeds that are already present and just adds new ones (like for long paragraphs). Other Considerations: You really need to take a look at the source of the message -- either write it to a file or CC yourself on the email. Find out what mail client is being used when this happens, is it always the same one or does this happen across multiple clients? Is it possible that a value in a cell actually contains HTML special characters? Be sure to run the values through htmlspecialchars() or htmlentities() to prevent data from scrambling the page. Quote Link to comment https://forums.phpfreaks.com/topic/256668-html-email-showing-code/#findComment-1315808 Share on other sites More sharing options...
matte Posted February 8, 2012 Author Share Posted February 8, 2012 great, I will try these suggestions and try to report back. Sometimes it might go 2 months before it happens again so it might be a while before i report back. Thanks for the suggestions guys! Quote Link to comment https://forums.phpfreaks.com/topic/256668-html-email-showing-code/#findComment-1315834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.