yafeearun
386
13
Laravel

htmlspecialchars() expects parameter 1 to be string, object given

Posted 3 months ago by yafeearun

Hi guys i have tried to send a mail and i write a mailable like

public function build()
    {
        $address = '[email protected]';
        $subject = 'This is a demo!';
        $name = 'Jane Doe';

        // print_r($this->data['message']);die();
        return $this->view('emails.test')
                    ->from($address, $name)
                 ->cc($address, $name)
                 ->bcc($address, $name)
                    ->replyTo($address, $name)
                 ->subject($subject)
                 ->with([ "message" => $this->data['message'] ]);
    }

even i have passed as string like ->with([ "message" => "test message"]);

but i got htmlspecialchars() expects parameter 1 to be string, object given, i tried to solve but i can't find out the exact solution. help me to solve this issue

when i tried load as a view

public function index(){
      return view('emails.test',['message' => 'This is a test!']);
}

works fine

<html lang="en-US">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
        <h2>Test Email</h2>
        <p>This is a test!</p>
    </body>

Please sign in or create an account to participate in this conversation.