Jump to content

[SOLVED] Line breaks not working in mail


Andy17

Recommended Posts

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<no-reply@hqdesigns.net>";

$comment = mysql_real_escape_string(nl2br($_POST['newcomment_field']));

mail($email, $subject, $comment, $headers);

?>

 

Any help is much appreciated!

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.