Reputation: 117
Emails works fine with dummy data:
Mail::send('emails.contact', $messageData, function ($message) use ($messageData) {
$message->from('[email protected]', 'Joe');
$message->to('[email protected]','Joe T')->subject('Email Test');
});
But when I try to pass data into the email, it won't send. I know a common problem is not passing through data with the use ($data), but I am doing this and it's still not working.
This is my code that will not 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('[email protected]','Joe T')->subject('Email Test');
});
I'm pretty stuck for ideas now!
Thanks
Upvotes: 2
Views: 2849
Reputation: 1
$data = array( 'email' => '[email protected]', 'first_name' => 'Lar', 'from' => '[email protected]', 'from_name' => 'Vel' );
Mail::send( 'email.welcome', $data, function( $message ) use ($data)
{
$message->to( $data['email'] )->from( $data['from'], $data['first_name'] )->subject( 'Welcome!' );
});
Upvotes: -1
Reputation: 60058
You cannot use $message
as your variable - see L4 docs here.
So change it to something like "msg" - i.e.:
$messageData = array(
'name' => 'test name',
'email' => 'test email',
'msg' => 'test message'
);
Upvotes: 5