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. Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/ 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. Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/#findComment-841192 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>? Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/#findComment-841423 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. Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/#findComment-841425 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. Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/#findComment-842064 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"; Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/#findComment-842066 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? Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/#findComment-842070 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"]); Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/#findComment-842813 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. Link to comment https://forums.phpfreaks.com/topic/159472-solved-in-non-html-email-from-php/#findComment-842816 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.