Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to get new line on sms message sent from php script

Tags:

php

sms

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.

like image 948
Matt Avatar asked Aug 18 '10 03:08

Matt


People also ask

How do I add a line break in my SMS message PHP?

Try with : "\r\n" and also don't forget to enclose your message with double quotes.

How do you make a new line in PHP?

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.

How can I send SMS using PHP?

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.


1 Answers

Use: %0a, worked for me in Nokia and Android

like image 50
Nasser Al-Wohaibi Avatar answered Oct 05 '22 06:10

Nasser Al-Wohaibi