margungijs's avatar

Sending mail through gmail not working

This is the error im receiving:

ErrorException: Undefined property: stdClass::$email in file /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php on line 725

This is the function i call the mail:

public function sendWelcomeEmail() { $title = 'test'; $body = 'test body';

    Mail::to('[email protected]')->send(new MyTestMail($title, $body));

    return "Email sent successfully!";
}

This is my mailable file (without the attachments):

public function __construct(private string $title, private string $body) { }

public function envelope(): Envelope
{
    return new Envelope(
        subject: 'My Test Mail',
    );
}

public function content(): Content
{
    return new Content(
        view: 'emails.email',
        with: [
            'title' => $this->title,
            'body' => $this->body,
        ],
    );
}
0 likes
0 replies

Please or to participate in this conversation.