hawkiq
370
4
Laravel

using Mailable got error undefined variable

Posted 1 year ago by hawkiq

Hello guys am totally new to use Mailable class I've creating mail send function likes below:

php artisan make:mail FeedbackMail

class FeedbackMail extends Mailable
{
    use Queueable, SerializesModels;

    public $feedbackmail;
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($feedbackmail)
    {
        $this->feedbackmail = $feedbackmail;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->from('[email protected]')
            ->view('emails.send')
            ->text('emails.send_plain');
    }
}

in my controller I use this code to send mail

$objMail = new \stdClass();
        $objMail->name = 'My Name';
        $objMail->content = 'My message to send';
        $objMail->from = 'from person';
        $objMail->subject = 'Message Subject';

        Mail::to("[email protected]")->send(new FeedbackMail($objMail));

my blade file


<!DOCTYPE html>
<html>
<head>
    <title>New Message from {{$feedbackmail->name}}</title>
</head>
<body>
<h1>New Message from {{$feedbackmail->name}} </h1>
<a href="mailto:{{$feedbackmail->from}}">{{$feedbackmail->from}}</a>
<p>Asking about : {{$feedbackmail->subject}}</p>
<p>{{$feedbackmail->content}}</p>
</body>
</html>

I got error undefined variable name in send.blade

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