How can send a mail with Attachment using laravel 5.5

Step:1- composer create-project laravel/laravel mail

Step:2 – Create Controller php artisan make:controller:SendEmailController This command will make SendEmailController.php file in app/Http/Controllers

Step:3- Go to the this path app/Http/Controllers/SendEmailController.php copy this code all and paste in this controller page SendEmailController.php

Step 4 – Create View Contact Form

Now we would make a view file for the display contact form on the web page. Below you can find the source code of contact form view file.

Step 5 – Set Route we have created under the Controller file. So here we will make two methods like index() and send() method under the controller. For this, we have to go to routes/web.php to set the route.

Step 6 – Create a Mailable class first you have to create an account in mailtrap or click this url https://mailtrap.io/ after create account you have to copy Username: XXXXXXXXX and password: XXXXXXXXXX and put in .env file see pic

Step:7- Now we are ready for make mailable class for this we have to go teminal and write following command. php artisan make:mail SendMail

This command will make SendMail.php file inside App\Mail\SendMail.php. In this class we have to define one property with name $data, by using this property we can pass data at the time of create an new instance of this class. App\Mail\SendMail.php

Step: 8 – Make View file for Email Body resources/views/dynamic_email_template.blade.php

Step:9- php artisan serve run this command and put url in your browser http://127.0.0.1:8000/sendemail

Ste

Total Page Visits: 133 - Today Page Visits: 1