SEVIZ Posted May 24, 2009 Share Posted May 24, 2009 Hey guys. I have a script I made that emails a message to peoples phones via text. Its very simple and just emails using normal php mail command. Everything is awesome except for one detail. I cannot hit enter in the message or else in the text you actually see "<br>". Is this a flaw in my code somehow? Obviously it is using html by adding the <br> and the phone cannot display an html message. How can I get it to insert a break when enter is hit without showing as <br> in the code? Or is there simply no way? Thanks I would post my code but its just a messagebox and submit. Let me know if you need it though. Quote Link to comment Share on other sites More sharing options...
eRott Posted May 24, 2009 Share Posted May 24, 2009 Couldn't you use \n for the line break? mail($to, $subject, "Hello,\n\nThis.\n\nGoodbye.", $headers) Result: Hello, This. Goodbye. Quote Link to comment Share on other sites More sharing options...
SEVIZ Posted May 24, 2009 Author Share Posted May 24, 2009 I can try that but I do not know how I could do that. Nowhere in the code did I set it to use <br> it is doing it by itself. Is there a way in the code to tell it to use /n instead of <br>? Quote Link to comment Share on other sites More sharing options...
jxrd Posted May 24, 2009 Share Posted May 24, 2009 Just replace all your <br>'s with \n. And it's \n not /n. Quote Link to comment Share on other sites More sharing options...
SEVIZ Posted May 26, 2009 Author Share Posted May 26, 2009 Maybe I am not explaining this right. The user is typing a message into a messagebox form. THEY are hitting enter for a new line and in the message that is sent it is inserting <br> all by itself. I cannot edit the code as I did not code that in. Quote Link to comment Share on other sites More sharing options...
iarp Posted May 26, 2009 Share Posted May 26, 2009 Add this to your $headers $header = "MIME-Version: 1.0" . "\r\n"; $header .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; Quote Link to comment Share on other sites More sharing options...
Andy-H Posted May 26, 2009 Share Posted May 26, 2009 Are you using nl2br() or str_replace() on the user input? Quote Link to comment Share on other sites More sharing options...
SEVIZ Posted May 27, 2009 Author Share Posted May 27, 2009 Andy> Yes I am using nl2br on the message. Like this: $MESSAGE_BODY = nl2br($_POST["message"]); Quote Link to comment Share on other sites More sharing options...
SEVIZ Posted May 27, 2009 Author Share Posted May 27, 2009 And that was it. Thank you Andy for spotlighting the obvious. Quote Link to comment 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.