send mail laravel code example
Example 1: laravel mail create
php artisan make:mail OrderShipped --markdown=emails.orders.shipped
Example 2: send html email laravel
// $data => array of information passed to view
Mail::send('email_view', $data, function ($m) use ($user) {
$m->from("[email protected]", config('app.name', 'APP Name'));
$m->to($user->email, $user->email)->subject('Email Subject!');
});
Example 3: laravel mail to specific email
$to = [
[
'email' => $email,
'name' => $name,
]
];
\Mail::to($to)->send(new \App\Mail\Hello);
Example 4: laravel mailable from
return (new Mail)
->to('[email protected]')
->from('[email protected]');