Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Foks's avatar
Level 15

How to add a \n in SMS?

Hello!

I'm trying to get the grip around SMS notifications in Laravel, one thing I don't seem to be able to be adding a new line, I've tried to use the \n and %0D%0A to achieve this, however, it adds it to the content, instead of a new line.

Any clues on how it works?

0 likes
7 replies
Snapey's avatar

How are you passing your string to the notification?

Foks's avatar
Level 15

@Snapey

    /**
     * Get the Vonage / SMS representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\VonageMessage
     */
    public function toVonage($notifiable)
    {
        return (new VonageMessage)
            ->clientReference((string) $notifiable->id)
            ->content('Ny opgave tildelt \n Kunde: sdfsdf %0D%0A Adresse: sdfsdf %0D%0A Opgave: sdfsdf %0D%0A Tid: sdfsdf %0D%0A Godstype: sdf');
    }
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Be sure to use " instead of ' to have php parse it as a newline

Foks's avatar
Level 15

@Sinnbeck I'm not really sure what you're suggesting, would you be able to elaborate on it?

Foks's avatar
Level 15

@Sinnbeck Thank you, I wasn't aware that the single quotes and double quotes mattered.

Please or to participate in this conversation.