Andy17 Posted July 21, 2009 Share Posted July 21, 2009 Hey, When I send out an e-mail, my line breaks are displayed as "\r\n" in the e-mails instead of being spaces. I am saving the messages in my MySQL database and there it says <br /> for every line break. I'm very tired so it's easier to show an example: The following This <br /> is a test <br /> for phpfreaks! would look the same in my MySQL database, but like this in the sent e-mail: This \r\nis a test \r\nfor phpfreaks! Here is the relevant parts of my code: <?php // Some variables here that are not important in regard to my problem $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "from: hqdesigns.net<[email protected]>"; $comment = mysql_real_escape_string(nl2br($_POST['newcomment_field'])); mail($email, $subject, $comment, $headers); ?> Any help is much appreciated! Link to comment https://forums.phpfreaks.com/topic/166718-solved-line-breaks-not-working-in-mail/ Share on other sites More sharing options...
Andy17 Posted July 21, 2009 Author Share Posted July 21, 2009 Bump. Link to comment https://forums.phpfreaks.com/topic/166718-solved-line-breaks-not-working-in-mail/#findComment-879352 Share on other sites More sharing options...
Q Posted July 21, 2009 Share Posted July 21, 2009 I'm not sure I understand your problem? Could you elaborate it? Link to comment https://forums.phpfreaks.com/topic/166718-solved-line-breaks-not-working-in-mail/#findComment-879364 Share on other sites More sharing options...
irkevin Posted July 21, 2009 Share Posted July 21, 2009 I heard it depends on which mail you are using. Some web host mail doesn't accept html.. It might work in hotmail ! Link to comment https://forums.phpfreaks.com/topic/166718-solved-line-breaks-not-working-in-mail/#findComment-879368 Share on other sites More sharing options...
Andy17 Posted July 21, 2009 Author Share Posted July 21, 2009 I'm not sure I understand your problem? Could you elaborate it? You know what <br /> does on an HTML page. I want it to do that in the e-mails I send as well, but instead it just writes out "\r\n" as text instead of actually making a line break as <br /> normally does. I heard it depends on which mail you are using. Some web host mail doesn't accept html.. It might work in hotmail ! My e-mail does allow this. I have actually had this problem before and I remember having to make a .htaccess file to turn off magicquotes or something. I did this again, but without luck this time. Link to comment https://forums.phpfreaks.com/topic/166718-solved-line-breaks-not-working-in-mail/#findComment-879431 Share on other sites More sharing options...
Andy17 Posted July 21, 2009 Author Share Posted July 21, 2009 Page 3 is not cool. Link to comment https://forums.phpfreaks.com/topic/166718-solved-line-breaks-not-working-in-mail/#findComment-879585 Share on other sites More sharing options...
Andy17 Posted July 21, 2009 Author Share Posted July 21, 2009 Just some information from phpinfo() (I believe the magic quotes are the problem somehow): Directive / Local Value / Master Value magic_quotes_gpc Off On magic_quotes_runtime Off Off magic_quotes_sybase Off Off My .htaccess file contains the following: php_flag magic_quotes_gpc Off Thank you in advance for any help. Link to comment https://forums.phpfreaks.com/topic/166718-solved-line-breaks-not-working-in-mail/#findComment-879680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.