Laravel - Mail class Exception

Posted by Christian Giupponi on Stack Overflow See other posts from Stack Overflow or by Christian Giupponi
Published on 2014-08-23T10:15:12Z Indexed on 2014/08/23 10:20 UTC
Read the original article Hit count: 198

Filed under:

I need to send email within my app and this is my code:

if( $agent->save() )
        {
            //Preparo la mail da inviare con i dati di login
            $data = [
                'nome' => $input['nome'],
                'cognome' => $input['cognome'],
                'email' => $input['email'],
                'password' => $input['password']
            ];

            //ATTENZIONE
            //Questo è da rimuovere in produzione, finge di inviare la mail
            Mail::pretend(); 

            //Recuero il template e passo alla funzione i dati
            Mail::send('emails.agents.registration', $data, function($message) use ($data)
            {                           
                $message->to( $data['email'], $data['nome'].' '.$data['cognome'] )->subject('Benvenuto!');
            });

            return Redirect::action('admin.agents.index')->with('positive_flash_message', 'Agente inserito correttamente.');
        }

As you can see I have use the Mail::pretend to avoid the email send in development, the problem is that I get this error every time I try to send an email:

Undefined property: Illuminate\Mail\Message::$email (View: /var/www/progetti/app/views/emails/agents/registration.blade.php) 

nd this is my blade view:

Email: {{ $message->email }}
Password: {{ $message->password }}

What's wrong with $message?

© Stack Overflow or respective owner

Related posts about laravel-4