Laravel 4 Mail not transferring data

Emails work fine with dummy data:

    Mail::send('emails.contact', $messageData, function ($message) use ($messageData) {
        $message->from('joetannorella@gmail.com', 'Joe');
        $message->to('joetannorella@gmail.com','Joe T')->subject('Email Test');
    });

      

But when I try to transfer data to an email, it doesn't get sent. I know the general problem is not transferring data using ($ data) , but I do it and it still doesn't work.

This is my code that won't work:

    $messageData = array(
        'name' => 'test name',
        'email' => 'test email',
        'message' => 'test message'
    );

    Mail::send('emails.contact', $messageData, function ($message) Use ($messageData) {
        $message->from($messageData['email'], $messageData['name']);
        $message->to('joetannorella@gmail.com','Joe T')->subject('Email Test');
    });

      

I'm stuck with ideas now!

thank

+2


source to share


2 answers


You cannot use $message

as your variable - see the L4 docs here .

So change it to something like "msg" - ie:



   $messageData = array(
        'name' => 'test name',
        'email' => 'test email',
        'msg' => 'test message'
    );

      

+5


source


$data = array( 'email' => 'sample@sample.com', 'first_name' => 'Lar', 'from' => 'sample@sample.comt', 'from_name' => 'Vel' );

Mail::send( 'email.welcome', $data, function( $message ) use ($data)
{
    $message->to( $data['email'] )->from( $data['from'], $data['first_name'] )->subject( 'Welcome!' );
});

      



-1


source







All Articles