I am trying to send simple email through mailgun and laravel, but getting a weird error.
I am not using queue just sending a simple welcome email on run time.
following is error:
Serialization of ‘Closure’ is not allowed
Following is mail send code:
$details = array(
'email' => $request->email,
'password' => $request->password,
);
Mail::send('emails.welcome', $details, function ($message) use ($user) {
$message->from('[email protected]', 'Admin');
$message->to($user->email);
});
When I comment above code, everything works fine.
2
Answers
I think you got the use of the closure wrong. This should work:
So basically, this is how you trigger the email:
OrderCreated class:
mail.mail_from is the blade view which would be used to create email that will be shown to the user.