Laravel Send Mail Without Mailable

So, I’m assuming that you know how to create a basic laravel project that’s why I’m starting with real action for sending mails.

First of all create view, which you want to send as a mail. Here I have a sample view with “Hello World!” text.

Image for post
Image for post
hello_world.blade.php

After creating view just create a controller. I’m creating controller named “SendMailController” .

Image for post
Image for post
Command for creating controller.

Here is the code of controller :

Image for post
Image for post
SendMailController.php

Create a route for calling controller’s method.

Image for post
Image for post
web.php

Finally configure your mail credentials in .env file. I’m using mailtrap as a mail host.

For those who don’t know about mailtrap, let me explain in short: mailtrap is mail host for testing your emails, it doesn’t send mails to actual email address, instead it stores email in inbox of your mailtrap account.

Image for post
Image for post
.env

Finally the results 🥳.

So i hope you liked this way of sending the mails.

Laravel Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store