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

julianov's avatar

add data in email template

Hello All, I need to share data in the email, with an url which has a hash code

Is there a way to add the hash code to the end of the link? Because this way is not working. You can see the code below.

changePassword.blade.php:

<!doctype html>
<html>
    <head>
        <title>The title</title>
        <meta name="description" content="Our first page">
        <meta name="keywords" content="html tutorial template">
    </head>
    <body>
        <div style="textAlign:center">
            <h1>{{$user->name }} {{$user->last_name}}</h1>
           
        
            <a href="http://urlpage.com/"+{{$hash}} >
      <input type="submit"/>
    </a>    
        </div>

    </body>
</html>

Mail.php

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

use App\Models\User;


class ChangePasswordUrl extends Mailable
{
    use Queueable, SerializesModels;

    public $user;
    public $hash;

    public function __construct(User $user, $hash)
    {
        $this->user = $user;
        $this->hash = $hash;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('changePassword', ['name' => 'The title']);
    }
}
0 likes
1 reply
kevinbui's avatar
kevinbui
Best Answer
Level 41

Instead of doing this:

<a href="http://urlpage.com/"+{{$hash}} >

What about this:

<a href="{{'http://urlpage.com/' . $hash}}">

Please or to participate in this conversation.