send mail in laravel code example

Example 1: email validation in laravel

'email' => 'required|email|unique:users,email',
//@sujay

Example 2: send multiple mail in laravel

$emails = ['[email protected]', '[email protected]','[email protected]'];

Mail::send('emails.welcome', [], function($message) use ($emails)
{    
    $message->to($emails)->subject('This is test e-mail');    
});
var_dump( Mail:: failures());
exit;

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]');

Example 5: email validation in laravel

$validator = Validator::make($request->all(), []);

 $validator->sometimes('email', 'unique:users,email', function ($input) {
            return $input->email !== Auth::user()->email;
        });
//@sujay