In this Laravel 7/6 tutorial, we will learn how to send emails from the Laravel application using the Mailtrap SMTP server. Generically, we will comprehend the working process of markdown mailable class and simultaneously work with every aspect required to send email securely, faster, and efficiently.

Send Simple Email in Laravel 7 with Mailable

Email sent from the Laravel application represent a mailable class; every mailable class is kept inside the app/Mail folder.

The php artisan make:mail your_class_name command forms the Mailable class, this also creates the blade view email template, which manages the mailer view.

What is Mailtrap?

Mailtrap is a traditional tool, and generically it is utilized as a fake SMPT (Simple Mail Transfer Protocol) server. Web developers and software development teams use it to send, test, view, and share emails, possibly sent from a staging environment without assimilating the spamming.

Workflow to Send an Email in Laravel

Sending mail from Laravel from the localhost environment can be assimilated by developers by the following process.

  1. Build a Laravel project.
  2. Create a Mailtrap account to handle requests from the local environment.
  3. Unite the Mailtrap details in the .env file.
  4. Formulate a Mailable class in Laravel.
  5. Generate Mail controller, write down the logic to send email
  6. Create a route, bind the mail controller to it.
  7. Create a mailer template in the view.
  8. Start your development server and send test emails.

Table of Contents

  1. Create Laravel Project
  2. Setting Up Mailtrap Mail Configuration
  3. Create Mailable Markdown Class
  4. Create Controller to Send and Email
  5. Create Route
  6. Create Email Template

Create Laravel Project

Install brand new Laravel project by executing the below-mentioned command.

composer create-project laravel/laravel --prefer-dist laravel-send-email

BashCopy

Move inside the newly created project directory.

cd laravel-send-email

#laravel

How to Send Email in Laravel 7 with Mailable and Mailtrap
4.65 GEEK