laravel attachment – Laravel Send Email with Multiple Attachment Example

laravel attachment with Send Email with Multiple Attachment is always cumbersome work in web application. Laravel provides a very simple api to send mail to users.

laravel attachment

Laravel latest version of the file attachment helpers. Today in this article We are going to show you how to send mail with laravel attachment.

Step 1: Install Laravel

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

Step 2: Make Configuration


[email protected]
[email protected]

Don’t miss : Unique Collection – Laravel Collection Get Unique Values Example

Step 3: Create Mail

In this phase i will make mail class SendDemoEmailExample for email sending.

php artisan make:mail SendDemoEmailExample


namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class SendDemoEmailExample extends Mailable
    use Queueable, SerializesModels;
    public $information_data;
     * Create a new message instance.
     * created by
     * @return void
    public function __construct($information_data)
        $this->information_data = $information_data;
     * Build the message.
     * created by
     * @return $this
    public function build()
        $this->subject('Mail from')
        foreach ($this->information_data['files'] as $file){
        return $this;

Step 4: Create Blade View


<!DOCTYPE html>
    <h2>{{ $information_data['title'] }}</h2>
    <p>{{ $information_data['body'] }}</p>
    <p>Thank you</p>

Step 5: Add Route


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\EmailController;
| Web Routes
| created by
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
Route::get('send-email', [EmailController::class, 'index']);

Step 6: Add Controller


namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Mail;
use App\Mail\SendDemoEmailExample;
class EmailController extends Controller
     * Write code on Method
     * created by
     * @return response()
    public function index()
        $files = [
        $information_data = [
            'title' => 'Mail from 2',
            'body' => 'Demo Example: This pakainfo is for testing email using smtp',
            'files' => $files
        Mail::to('[email protected]')->send(new SendDemoEmailExample($information_data));
        dd("Email is Sent.");

I hope you get an idea about laravel attachment.
I would like to have feedback on my
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.