3

Using PHP/Laravel.
And the latest Twilio library 5.16.2

Followed this - https://support.twilio.com/hc/en-us/articles/223181468-How-do-I-add-a-line-break-in-my-SMS-message-

And none of these work, they are sent as it is:

  • %0a
  • \n
  • %0D%0A

$textMessageToSend = $textMessageToSend . ' %0a ' . $emailLinkOfContent;

What am I missing ?

PlanetUnknown
  • 3,956
  • 4
  • 49
  • 67

2 Answers2

3

The problem is with the single quoted string use Double quotes to solve the issue,

$textMessageToSend = $textMessageToSend . "%0a" . $emailLinkOfContent;

make sure $textMessageToSend and $emailLinkOfContent are both strings assigned with double quotes if initialisation is hard-coded.

Naresh Kumar
  • 1,706
  • 1
  • 14
  • 26
2

I was using Twilio in Laravel about 2 months ago and I had no problem with sending SMS with content like this:

'Test'. "\n" .'new line'

it went to new line where it should but as you see in PHP you should use double quotes for new line to make it work.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291