Laravel Mailing Issue "Object of class Illuminate\Mail\Message could not be conv...

I'm trying to send a simple email. I know the issue is with my view but I don't know what I'm doing wrong.
Here is my controller:
            $user = Auth::user()->fullname;
            $id = Auth::user()->id;

            $data = array(
                'title' => Input::get('title'),
                'message' => Input::get('message'),
                'user' => $user,
                'id' => $id
            );

            Mail::send('emails.PlainMessage', $data, function($message)
            {

                $message->to('amilajack@gmail.com', 'ECULTURE')->subject('User has a comment/question');

            });
and here is my email view:
From: {{ $user }}, {{ $id }}

<br>
Title: {{ $title }}
<br>
Message: {{ $message }}
Thanks in advance!!!!
amilajack
amilajack
  • 1 month ago
    lol. Just a guess, maybe you should try avoid using the word message in your template.
    Actually I tried that and it still didn't work. I found that the error was that the textarea was returning something weird and not a string. That's my guess tho lol I still haven't found out
    Would you mind explaining what you have tried? If I remember correctly, $message in email template is used by the instance itself and it is useful for attaching attachment in the template.
    By looking at part of your error message, it looks like you were trying to echo out an object which isIlluminate\Mail\Message as string which it will certainly throw out an error when you do so.
    Or maybe there is actually more than one error ?
    awsp said:
    Would you mind explaining what you have tried? If I remember correctly, $message in email template is used by the instance itself and it is useful for attaching attachment in the template.
    By looking at part of your error message, it looks like you were trying to echo out an object which isIlluminate\Mail\Message as string which it will certainly throw out an error when you do so.
    Or maybe there is actually more than one error ?
    Thanks pal, you just helped me. I was using message keyword as well
        $data = array(
                        'message' => $askerMessage
                    );
    
    and in blade template : {{ $message }}
    I changed it to messages and it worked. Cheers
        $data = array(
                        'messages' => $askerMessage
                    );
    
    and in blade template : {{ $messages }}

    Comments

    Popular posts from this blog

    Bootstrap Tags Input

    Laravel 5.8 Files Folders Permissions and Ownership Setup