How To Send Email With Attachment In Laravel 8

Websolutionstuff | May-05-2021 | Categories : Laravel PHP

In this tutorial i will show you how to send email with attachment in laravel 8. As we all know mail functionalities are common in all project but if you want to send mail with attechment then this post is for you here we will see how to attach file in mail in laravel 8.

Here,we will send attachment in mail in laravel 8. So, Let's start and follow below steps.

Step 1 : Set Configuration for send email

Step 2 : Add Route

Step 3 : Add Controller

Step 4 : Create Blade File


Step 1 : Set Configuration for send email

First of all we need to add send email configuration with mail driver, mail host, mail port, mail username, mail password etc in your .env file

MAIL_USERNAME=Your user name


Step 2 : Add Route

Now, add route in your routes/web.php file.

Route::get('send/mail', [SendMailController::class, 'send_mail'])->name('send_mail');


Step 3 : Add Controller

Now create SendMailController in your project and copy below code for attach file in mail.


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Mail;

class SendMailController extends Controller
    public function send_mail(Request $request)
        $data["email"] = "[email protected]";
        $data["title"] = "";
        $data["body"] = "This is test mail with attachment";
        $files = [
        Mail::send('mail.Test_mail', $data, function($message)use($data, $files) {
            foreach ($files as $file){

        echo "Mail send successfully !!";


Step 4 : Create Blade File

Now, create blade file in this file location resources\views\mail\Test_mail.blade.php for display messages in mail

Hi, Websolutionstuff <br/>
This is Test Mail.<br />
Thank you...!!


And finally you will get output like below image.



Recommended Post
Featured Post
Laravel 8 Export Buttons In Datatables Example
Laravel 8 Export Buttons In Da...

In this article, we will see an example of laravel 8 export buttons in datatables. If you want to export data...

Read More


How To Add Digital Signature In PDF In Laravel 9
How To Add Digital Signature I...

In this article, we will see how to add a digital signature in pdf in laravel 9. Here, we will learn to add a digit...

Read More


How to Send E-mail Using Queue in Laravel 7/8
How to Send E-mail Using Queue...

Today I will show you how to send e-mail using queue in laravel 7/8, many times we can see some processes take...

Read More


Laravel 10 CRUD Operation Step By Step
Laravel 10 CRUD Operation Step...

In this article, we will see how to create a crud operation in laravel 10. Here, we will learn about laravel 10 crud ope...

Read More