Learn how to send emails in laravel in easy way

Laravel’s Mail class extends the popular Swift Mailer package, which makes sending e-mails a breeze. The e-mail templates are loaded in the same way as views, which means you can use the Blade syntax and inject data into your templates:

  • To inject some data into a template located inside resources/views/email/view.blade.php, we use the following function:
    Mail::send('email.view', $data, function($message) {});
  • To send both an HTML and a plain text version, we use the following function:
    Mail::send(array('html.view', 'text.view'), $data, $callback);
  • To delay the e-mail by 5 minutes (this requires a queue), we use the following function:
    Mail::later(5, 'email.view', $data, function($message) {});
Recommended :  Secure your laravel app And website Using these Tips

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest

Shares