I've been trying to get a new line generated in my SMS message sent from a PHP script. I've used \r\n
, <BR>
and some hex codes. No matter what I do the message comes to my phone without line breaks.
$body .= 'City:'.$venue.'\r\n'; //<- doesn't work $body .= 'State:'.$state.'<br>'; //<- doesn't work
This is my header type...(complete header not included)
$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
I use mail to send...
mail($somenumber,$subject,$body,$headers)
Everything works fine in the sense that I receive the message. I hope that I'm missing something, because this is driving me crazy.
Try with : "\r\n" and also don't forget to enclose your message with double quotes.
Answer: Use the Newline Characters ' \n ' or ' \r\n ' You can use the PHP newline characters \n or \r\n to create a new line inside the source code. However, if you want the line breaks to be visible in the browser too, you can use the PHP nl2br() function which inserts HTML line breaks before all newlines in a string.
To send an SMS through PHP to Mr. Example, you could simply add [email protected] to any email client, type a message, and hit send. This will send a text message to phone number +1 (385) 555-0168 on the Verizon Wireless Network. For example, I'll send a text message to myself using Gmail.
Use: %0a
, worked for me in Nokia and Android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With