Create Approval system in Laravel using mailtrap.


In this tutorial, I will teach how to sending mail in laravel and how to mail systems used to approve your post and how it will help in big projects.

You have to just follow my steps and understanding the concepts.

Step 1: Open the

You have open the in your browser and if you already create an account then click on the login button otherwise signup button click and create a new account.

Step 2: Email Configuration.

After login or signup in, you have got information about credentials.

You have to put these credentials into your .env file.

MAIL_USERNAME= //username from your mailtrap credentials.
MAIL_PASSWORD= //password from your mailtrap credentials.

Step 3: Create a Mail sending class.

So open your terminal OR command prompt and run bellow command:

php artisan make:mail NewPostMail

In this step, we have to find App\Mail\NewPostMail.php and put the below code.


namespace App\Mail;

use App\Post;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class NewPostMail extends Mailable
    use Queueable, SerializesModels;

     * Create a new message instance.
     * @return void
    public function __construct($post)
        $this->post = $post;

    public function build()
        return $this->view('')->with("post", $this->post);

Step 4: Create Blade Files

In this step, we have to find resources/views and create a new folder name emails & create a new file post.blade.php and put the below code.

<!DOCTYPE html>
    <title>Welcome Email</title>
		Your Post is {{ $post['title'] }}
		Post created by {{ $post->userDetail->name }}

Post-Create Page:

Step 5: Open your Controller.

In this step, we have to find PostController.php in your app/Http/Controller and put the below code on the store method.

You have to use the store method because of store method stores in database & and directly sending mail.

public function store(Request $request){
        $post =  new Post;
        $post->title = $request->title;
        $post->user_id = Auth::User()->id;
        $post->body = $request->body;

        Mail::to('your mail id which you are login')->send(new NewPostMail($post));
        return redirect('posts');

After Post Create:

After Post create you got an email on

Now we are ready to run our task with laravel , so run bellow command for the run:

php artisan serve

Now you have to open your browser and put below URL:


About Dhaval Shah

My name is Dhaval Shah. I'm a Laravel developer. I live in India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Java-script, JQuery, Laravel, WordPress, and Bootstrap.
Follow me on Github / Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!