Support & Downloads

Quisque actraqum nunc no dolor sit ametaugue dolor. Lorem ipsum dolor sit amet, consyect etur adipiscing elit.

s f

Contact Info
198 West 21th Street, Suite 721
New York, NY 10010
[email protected]
+88 (0) 101 0000 000

Send Email with Attachment in Laravel

This post will give you example of how to send email with attachment in laravel.In this article, we will implement sending attachment in mail in laravel. Alright, let’s dive into the steps.
This tutorial of sending mail with attachment can be implemented in following versions of laravel:- laravel 6,7,8.

Step 1: Install Laravel

I am going to explain step by step from scratch so, we need to get fresh Laravel application using bellow command, So open your terminal OR command prompt and run below command:

Step 2: Make Configuration

In first step, you have to add send mail configuration with mail driver, mail host, mail port, mail username, mail password so laravel will use those sender details on email. So you can simply add as like following.

.env

Step 3: Add Route

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

routes/web.php

Step 4: Add Controller

Here,we require to create new controller PDFController that will manage generatePDF method of route.

make sure you have “files” folder in public with following files.

So let’s put below code.

app/Http/Controllers/PDFController.php

Step 5: Create View File

In Last step, let’s create myTestMail.blade.php(resources/views/emails/myTestMail.blade.php) for layout of pdf file and put following code:

resources/views/emails/myTestMail.blade.php

Now you can run and check example.

It will send you email, let’ see.

Run Project:

Now hit URL as given below or you can run according to your routes:

Post a Comment