Site Admin
Site Admin Founder of MeaningArticles

Laravel 8 Send Email With File Attachment

Hello Dev.
nowadays i can defined to the way to send mail with file attachment in laravel 8. the way to send email with file attachment in laravel eight is so easy to you can simply comply with my step by step and discover ways to send mail with file attachment in laravel 8.

we can use how to send attachment in mail the usage of could see the way to attach file in mail in laravel and implement a send attachment in mail in laravel.

we can send email with attachment in laravel 6, laravel 7 and laravel 8 application. and send email with upload file as attechment with sending mail in just comply with for a my few step to create a sending mail with attechment.

So let's start to the example

Step 1: Install Laravel 8

first of all we want to get clean and new Laravel eight version application the use of bellow command, now open your terminal OR command prompt and then fire bellow command and run it:

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


Step 2: .Env

subsequent step to your project .env file to add the mail configration in your project and configure your project.

[email protected]
[email protected]

Step 3: Add Route

In this is step we want to create routes for items listing. so open your "routes/web.php" file and add following route.

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SendMailController; 
| Web Routes
| here is wherein you may register web routes for your application. these
| routes are loaded with the aid of the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something tremendous!|
Route::get('send-email-file-attecment', [SendMailController::class, 'index']);


Step 4: Add Controller

Next step to you can create a new SendMailController in your current laravel 8 project.

So let's put bellow code in SendMailController.php file.



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

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

    public function index()
        $data["email"] = "[email protected]";
        $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

Finally last step you can create a blade file in fileAttechmemtMail.blade.php(resources/views/emails/fileAttechmemtMail.blade.php) for a layout file and use the code.


<!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

You check the app on http://localhost:8000/send-email-file-attecment
i'm hoping it assist you to, thanks for visit my article if you like my article then proportion together with your friend and social platform.