I don't know if this is possible
I am trying to send custom email all the users from my users table. I am using the mail fascades present in laravel.
There is a blade template like this :
@component('mail::message')
# New Book Lunch
This is the body of the email.
@component('mail::button', ['url' => $url ?? ''])
View Order
@endcomponent
Thanks,<br>
{{ config('app.name') }}
@endcomponent
My method to send mail looks like this
class NewsLetterController extends Controller
{
public function newsletter(Request $request)
{
$subject = $request->name;
$message = $request->message;
$email = User::pluck('email');
Mail::to($email)->(Add my custom $message and $subject)->send(new NewsLetter());
}
}
Here I want to add a custom message and subject my filling a form. How can that be done so I can add custom message?
Looking at the docs: https://laravel.com/docs/8.x/mail#sending-mail
You can pass the variables to the Mailable via the constructor.
And in the Mailable:
If you want to pass the message to the view, your
build
could look like:And finally, you add the message in blade: