Join WhatsApp ChannelJoin Now

Laravel 8 Send Email With File Attachment

Hi Dev,

Today, i we will show you laravel 8 send email with file attachment. This article will give you simple example of laravel 8 send email with file attachment. you will laravel 8 send email with file attachment. In this article, we will implement a laravel 8 send email with file attachment.

We will use the way to send attachment in mail victimisation laravel.You can see the way to attach get in mail in laravel and implement a send attachment in mail in laravel.

We can send email with attachment in laravel vi, laravel seven and laravel eight application. and send email with add file as attechment with causation mail in exactly follow for a my few step to form a causation mail with attechment.

So let’s follow few step to create example of laravel 8 send email with file attachment.

Step 1: Install a New Laravel

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

Step 2: .Env


Step 3: Add Route


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

Route::get('send-email-file-attecment', [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>


php artisan serve

I hope it will assist you…

Recommended Posts