1 year ago

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]')

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>
    <title>New Message from {{$feedbackmail->name}}</title>
<h1>New Message from {{$feedbackmail->name}} </h1>
<a href="mailto:{{$feedbackmail->from}}">{{$feedbackmail->from}}</a>
<p>Asking about : {{$feedbackmail->subject}}</p>

I got error undefined variable name in send.blade

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