How To Send Email With Attachment In Laravel 8

In this article, we will see how to send an email with an attachment in laravel 8. As we all know mail functionalities are common in all projects but if you want to send a mail with an attachment then this post is for you here we will see how to attach files in mail laravel 8.

So, let's see how to send attachments in the mail using laravel 8, how to attach files in the mail in laravel 8, send multiple attachments in mail laravel 8, laravel 8 send an email with PDF attachments, send multiple attachments in mail laravel 8, how to send image in the mail using laravel 8.

Step 1 : Set Configuration for Sending Email with Attachments

Step 2 : Add Routes

Step 3 : Add Controller

Step 4 : Create Blade File


Step 1 : Set Configuration for Sending Email with Attachments

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




Step 2 : Add Route

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

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


Step 3 : Add Controller

Now, we will create SendMailController and copy the below code for the attached file in the mail.


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Mail;

class SendMailController extends Controller
    public function send_mail(Request $request)
        $data["email"] = "";
        $data["title"] = "";
        $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 a blade file in this file location resources\views\mail\Test_mail.blade.php for display messages in the mail

This is test mail with attachments.<br />
Thank you !!

Output :



You might also like :


Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.