How to Send Email with Attachment in Laravel 8

How to Send Email with Attachment in Laravel 8

In this example you learn how to send email with attachment in laravel 8 project.  you can send email with attachment file in laravel 8. The attach() method to you can simply attach file and send mail.

We will use how to send attachment in mail using laravel. In this example we discuss on laravel 8 send mail with attach file. You can see how to attach file in mail in laravel and implement a send attachment in mail in laravel.

Read Also :  Laravel 8 Add Watermark on Image

After read this post you simply send email with attachment in laravel 6, laravel 7 and laravel 8 application.

Laravel 8 Send Email With File Attachment

Step 1: Install Laravel

composer create-project --prefer-dist laravel/laravel blog

Step 2 : Change.Env


Step 3: Add Route

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SendMailController; 

Route::get('send-email-file-attacment', [SendMailController::class, 'index']);

Step 4: Add new SendMailController


namespace App\Http\Controllers;
use PDF;
use Mail;

class SendMailController extends Controller
     * Write code on Method
     * @return response()

    public function index()
        $data["email"] = "";
        $data["title"] = "From";
        $data["body"] = "This is Demo Mail Attechment Pdf File";

        $attechfiles = [

        Mail::send('emails.fileAttechmemtMail', $data, function($message)use($data, $attechfiles) {
            $message->to($data["email"], $data["email"])
            foreach ($attechfiles as $file){

        dd('Mail sent successfully Check Send Mail Email Address.');

Step 5: Add View File


<!DOCTYPE html<
    <h1>File Attechment Mail,</h1>
    <p>This Is File Attechment Mail Example,</p>
    <p>Thank You.</p>

So, finally now you can run the code in check the example

php artisan serve

I hope you understand of laravel send email with attachment and it can help you…

Read Also :  Laravel Migration Add Default Value Example