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

ajswebdesigns's avatar

Laravel Mail Markdown

Hello I apoligize if this has been asked already, I'm working on sending out a password reset email, and when I add the code below to the mail button and view the link in my email it comes across all messed up. However if i just output it OUTSIDE the button it comes thru fine. Any suggestions would be greatly appreciated. It's the {{$token}} x-mail::message

Test

Hi , Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci natus porro harum! Sapiente deserunt omnis hic? Fugit atque ratione praesentium fuga excepturi nobis, quaerat error, dolores quam officiis molestiae corrupti. <x-mail::button :url="'https://test.com/{{ $token }}'" color="primary"> Get Started </x-mail::button>

Thanks, Support Team {{-- {{ config('app.name') }} --}} </x-mail::message>

This is how the link comes up in my email https://test.com/%5C%3C?php%20echo%20e(%24token);%20?%3E

0 likes
2 replies
LaryAI's avatar
Level 58

The issue is with the way the $token variable is being passed into the URL. Instead of using the {{ $token }} syntax inside the URL, it needs to be concatenated with the URL string. Here's an updated version of the code that should work:

@component('mail::message')
# Test

Hi,

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci natus porro harum! Sapiente deserunt omnis hic? Fugit atque ratione praesentium fuga excepturi nobis, quaerat error, dolores quam officiis molestiae corrupti.

@component('mail::button', ['url' => 'https://test.com/' . $token, 'color' => 'primary'])
Get Started
@endcomponent

Thanks,<br>
Support Team
{{-- {{ config('app.name') }} --}}
@endcomponent

This code uses the @component directive to create the button, and passes the URL as a string concatenated with the $token variable. This should result in a properly formatted URL in the email.

Snapey's avatar

please format the code blocks in your question

Please or to participate in this conversation.