SlideShare a Scribd company logo
Laravel Mail
Example: How
to Send an
Email using
Markdown
Template in
Laravel 8?
www.bacancytechnology.com
Sending an email is one most important
features of any project. In this tutorial, you
will learn how to send emails using
Markdown Template with the help of
Laravel Mail Example. Implementation of
the Markdown template is not a difficult
task. Yes, you heard it correctly! But, still
you haven’t played around it, here’s a step-
by-step tutorial, that will provide you with
instructions for sending an email using
Markdown.
CONTENTS
Tutorial Goal: Laravel Mail Example
using Markdown Template
1.
2. Step-by-step guidelines: Laravel Mail
Example: How to Send an Email using
Markdown Template in Laravel 8?
3. Conclusion
Tutorial Goal:
Laravel Mail
Example
using
Markdown
Template
Before diving into building a demo
application, let’s see this video to clarify
what we are building here.
https://youtu.be/RXeAD0qOEB8
The user will enter the name and email
address, and after clicking on submit
button, an email will be sent to the entered
email address. Login to that email address,
and there you can see the email.
Step-by-step
guidelines:
Laravel Mail
Example: How
to Send an
Email using
Markdown
Template in
Laravel 8?
Step 1: Create Laravel Project
composer create-project laravel/laravel --
prefer-dist BacancyEmail
We are going to Set Mail Configuration here.
For that, we will add our Gmail SMTP
configuration such as name, password, etc.
(Allow two-step verification and control
access to less secure apps. in Gmail). We will
use our .env file and add the configurations,
which are described below.
.env
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=prashantkhunt1999@gmail.com
MAIL_PASSWORD= (third party app password <a
href="https://support.google.com/accounts/answer/
185833?hl=en" target="_blank">click hear</a>)
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=prashantkhunt1999@gmail
.com
MAIL_FROM_NAME="${APP_NAME}"
Step 2: Configuration Setup.
In this section, we will create Mailable Class
with Markdown. A new Mailable class,
which provides us to use Laravel event. It
also provides the facility to re-use them
anywhere in the application. For this, we
will first create a class of Mailable, and for
that, we will run the below artisan
command-
Step 3: Create Mail with
Markdown
php artisan make:mail BacancyMail --
markdown=emails.BacancyMail
app/Mail/BacancyMail.php
resources/views/emails/BacancyMail.bl
ade.php
By running the above command, two files
are generated:
Open the BacancyMail.php file in our app
folder and then write the below code.
app/Mail/BacancyMail.php
<?php
namespace AppMail;
use IlluminateBusQueueable;
use
IlluminateContractsQueueShouldQueue;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
use Queueable, SerializesModels;
public $body;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($body)
{
$this->body = $body;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.BacancyMail')-
>with('body',$this->body);
}
}
Step 4: Create a Controller
for Mail.
In this step, we are going to create
Controller Method. We will Create
MailController as a new controller. Run the
following command to create
MailController.
php artisan make:controller MailController
Now we will use our MailController file and
add the sendMail() function into it. Using this
file, we can quickly write the mail send code,
which is described as follows.
<?php
namespace AppHttpControllers;
use AppMailBacancyMail;
use IlluminateHttpRequest;
use Mail;
class MailController extends Controller
{
public function sendMail(Request $request)
{
$data = $request->validate([
'name'=>'required',
'email'=>'required|email'
]);
$email = $data['email'];
$body = [
'name'=>$data['name'],
app/http/Controllers/MailController
'url_a'=>'https://www.bacancytechnology.com/',
'url_b'=>'https://www.bacancytechnology.com/t
utorials/laravel',
];
Mail::to($email)->send(new
BacancyMail($body));
return back()->with('status','Mail sent
successfully');;
}
}
Step 5: Create a simple form
Moving forward towards our Laravel Mail
Example, now we will create one form in
this step that takes the name and email
from the user.
Open resources/views/welcome.blade.php
and add the below-mentioned code in the
body section of the welcome page.
resources/views/welcome.blade.php
<body class="antialiased">
<div
class="relative flex items-top justify-center min-
h-screen bg-gray-100 dark:bg-gray-900 sm:items-
center py-4 sm:pt-0">
<div class="max-w-6xl mx-auto sm:px-6 lg:px-
8">
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
<div class="flex justify-center pt-8 sm:justify-
start sm:pt-0">
<h1>Bacancy Technology Mail Sending
Tutorials</h1>
</div>
<div class="mt-8 bg-white dark:bg-gray-800 overflow-hidden
shadow sm:rounded-lg">
<div class="grid grid-cols-1 md:grid-cols-2">
<div class="p-6">
<div class="ml-12">
<form action="{{route('send.email')}}" method="POST">
@csrf
<h6>Enter Name</h6>
<input style="background:DarkGrey; width:500px;
height:35px" type="text" name="name" value="" />
<br>
<h6>Enter Email </h6>
<input style="background:DarkGrey; width:500px;
height:35px" type="email" name="email" id="email">
<br><br><br>
<input class="btn btn-dark btn-block" type="submit"
value="submit" name="submit">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
The UI would be something like this-
In step 3, we have created a blade file
named BacancyMail.blade.php for an email
template. This file will be useful to write the
design code. We will add the below code
into that file.
resources/views/emails/BacancyMail.blade.
php
@component('mail::message')
<h1>Hello {{$body['name']}},</h1>
<p>The email is a sample email for Laravel
Tutorial: How to Send an Email using
Laravel 8 from @component('mail::button',
['url' => $body['url_a']])
Bacancy Technology
@endcomponent</p>
Step 6: Create Body for the
Mail.
<p>Visit @component('mail::button', ['url' =>
$body['url_b']])
Laravel Tutorials
@endcomponent and learn more about the
Laravel framework.</p>
Happy coding!<br>
Thanks,<br>
{{ config('app.name') }}<br>
Laravel Team.
@endcomponent
In this step, we are going to Create Route.
We will create this for our testing mail. For
this, we will use our web route file; go to the
web.php file and define the following route.
web.php
Route::get('/', function () {
return view('welcome');
});
Route::post('/sendBacancyMail',
[MailController::class,'sendMail'])-
>name('send.email');
Step 7: Define the Route.
Now, finally we are done with out Laravel
mail example. Run the project by using this
command:
php artisan serve.
Step 8: Run the project
Hit http://127.0.0.1:8000/, and you’ll see the
user interface. Enter the name and email
address; you’ll receive an e-mail on that email
id.
You can find the entire the source code here –
Github Repository.
Conclusion
So, this was a beginner’s guide on how to
send email using the Markdown template in
Laravel 8. Laravel Mail example was pretty
straightforward, right? So, clone the github
repository and start playing around with
the code! I hope the Laravel Markdown
email example was helpful to you. Visit
Laravel Tutorial to explore more about
Laravel.
Bacancy Technology has dedicated and
skilled Laravel developers. Are you looking
for a Laravel expert? If yes, then without
wasting a second, contact us and hire
Laravel developer. We ensure to provide the
best and proficient Laravel developers who
can meet your requirements.
Happy Coding!
Thank You
www.bacancytechnology.com

More Related Content

What's hot

Slurry erosion test rig
Slurry erosion test rigSlurry erosion test rig
Slurry erosion test rig
Pawan Kumar
 
Isomerism
IsomerismIsomerism
Isomerism
Sachith Gamage
 
Osmium Tetroxide
Osmium Tetroxide Osmium Tetroxide
Osmium Tetroxide
Sudha durairaj
 
hydrogen bond 2 by KK Sahu sir
hydrogen bond 2 by KK Sahu sirhydrogen bond 2 by KK Sahu sir
hydrogen bond 2 by KK Sahu sir
KAUSHAL SAHU
 
Crystal structures
Crystal structuresCrystal structures
Crystal structures
SAI SUBHASH PAVAN VARMA
 
Ch03
Ch03Ch03
Ch03
klivsie
 
Resonance
ResonanceResonance
Resonance
Jahnn Drigo
 
.Electron diffraction for m.sc, student complete unit
.Electron diffraction for m.sc, student complete unit.Electron diffraction for m.sc, student complete unit
.Electron diffraction for m.sc, student complete unit
shyam sunder pandiya
 
Lecture 2 3 protein chemistry
Lecture 2 3 protein chemistryLecture 2 3 protein chemistry
Lecture 2 3 protein chemistry
Abo Ali
 
Role of metal ions
Role of metal ionsRole of metal ions
Role of metal ions
Falana Benedict
 
Proteins.pptx
Proteins.pptxProteins.pptx
Proteins.pptx
Kayeen Vadakkan
 
Crystal field theory
Crystal field theoryCrystal field theory
Crystal field theory
surya287
 
potentiometry and ion selective electrodes
potentiometry and ion selective electrodespotentiometry and ion selective electrodes
potentiometry and ion selective electrodes
Animikh Ray
 
Chapter 1: Electronic Structure and Bonding Acids and Bases
Chapter 1: Electronic Structure  and Bonding Acids and BasesChapter 1: Electronic Structure  and Bonding Acids and Bases
Chapter 1: Electronic Structure and Bonding Acids and Bases
Vutey Venn
 
Stereochemistry of Alkanes and Cycloalkanes
Stereochemistry of Alkanes and CycloalkanesStereochemistry of Alkanes and Cycloalkanes
Stereochemistry of Alkanes and Cycloalkanes
Nilesh Thakare
 
Trans effect
Trans effectTrans effect
Trans effect
Ateeqa Amjad
 
Chirality in the nature
Chirality in the natureChirality in the nature
Chirality in the nature
caucasus international university
 
Coenzymes and their functions
Coenzymes and their functionsCoenzymes and their functions
Coenzymes and their functions
Sarah Hamid
 
COMPREHENSIVE HANDOUT FOR ORGANIC CHEMISTRY
COMPREHENSIVE HANDOUT FOR ORGANIC CHEMISTRYCOMPREHENSIVE HANDOUT FOR ORGANIC CHEMISTRY
COMPREHENSIVE HANDOUT FOR ORGANIC CHEMISTRY
Paolo Naguit
 
Fatigue life assessment by haagensen
Fatigue life assessment by haagensenFatigue life assessment by haagensen
Fatigue life assessment by haagensen
Avinash B
 

What's hot (20)

Slurry erosion test rig
Slurry erosion test rigSlurry erosion test rig
Slurry erosion test rig
 
Isomerism
IsomerismIsomerism
Isomerism
 
Osmium Tetroxide
Osmium Tetroxide Osmium Tetroxide
Osmium Tetroxide
 
hydrogen bond 2 by KK Sahu sir
hydrogen bond 2 by KK Sahu sirhydrogen bond 2 by KK Sahu sir
hydrogen bond 2 by KK Sahu sir
 
Crystal structures
Crystal structuresCrystal structures
Crystal structures
 
Ch03
Ch03Ch03
Ch03
 
Resonance
ResonanceResonance
Resonance
 
.Electron diffraction for m.sc, student complete unit
.Electron diffraction for m.sc, student complete unit.Electron diffraction for m.sc, student complete unit
.Electron diffraction for m.sc, student complete unit
 
Lecture 2 3 protein chemistry
Lecture 2 3 protein chemistryLecture 2 3 protein chemistry
Lecture 2 3 protein chemistry
 
Role of metal ions
Role of metal ionsRole of metal ions
Role of metal ions
 
Proteins.pptx
Proteins.pptxProteins.pptx
Proteins.pptx
 
Crystal field theory
Crystal field theoryCrystal field theory
Crystal field theory
 
potentiometry and ion selective electrodes
potentiometry and ion selective electrodespotentiometry and ion selective electrodes
potentiometry and ion selective electrodes
 
Chapter 1: Electronic Structure and Bonding Acids and Bases
Chapter 1: Electronic Structure  and Bonding Acids and BasesChapter 1: Electronic Structure  and Bonding Acids and Bases
Chapter 1: Electronic Structure and Bonding Acids and Bases
 
Stereochemistry of Alkanes and Cycloalkanes
Stereochemistry of Alkanes and CycloalkanesStereochemistry of Alkanes and Cycloalkanes
Stereochemistry of Alkanes and Cycloalkanes
 
Trans effect
Trans effectTrans effect
Trans effect
 
Chirality in the nature
Chirality in the natureChirality in the nature
Chirality in the nature
 
Coenzymes and their functions
Coenzymes and their functionsCoenzymes and their functions
Coenzymes and their functions
 
COMPREHENSIVE HANDOUT FOR ORGANIC CHEMISTRY
COMPREHENSIVE HANDOUT FOR ORGANIC CHEMISTRYCOMPREHENSIVE HANDOUT FOR ORGANIC CHEMISTRY
COMPREHENSIVE HANDOUT FOR ORGANIC CHEMISTRY
 
Fatigue life assessment by haagensen
Fatigue life assessment by haagensenFatigue life assessment by haagensen
Fatigue life assessment by haagensen
 

Similar to Laravel mail example how to send an email using markdown template in laravel 8

Task scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorialTask scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorial
Katy Slemon
 
Node mailer example how to send email using nodemailer with gmail &amp; mailtrap
Node mailer example how to send email using nodemailer with gmail &amp; mailtrapNode mailer example how to send email using nodemailer with gmail &amp; mailtrap
Node mailer example how to send email using nodemailer with gmail &amp; mailtrap
Katy Slemon
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
Katy Slemon
 
Action Mailer
Action MailerAction Mailer
Action Mailer
SHC
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdf
Katy Slemon
 
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
singingfish
 
CICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your MindCICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your Mind
ciconf
 
Object Oriented Programming With PHP 5 #2
Object Oriented Programming With PHP 5 #2Object Oriented Programming With PHP 5 #2
Object Oriented Programming With PHP 5 #2
Wildan Maulana
 
Build Your Own Instagram Filters
Build Your Own Instagram FiltersBuild Your Own Instagram Filters
Build Your Own Instagram Filters
TJ Stalcup
 
Ruby On Rails Starter Kit
Ruby On Rails Starter KitRuby On Rails Starter Kit
Ruby On Rails Starter Kit
El Orabi Mohamed Ikbal
 
How to add watermark to image using php
How to add watermark to image using phpHow to add watermark to image using php
How to add watermark to image using php
YourBlogCoach1
 
mush With Xampp
mush With Xamppmush With Xampp
Installing configuringdevelopingwithxampp
Installing configuringdevelopingwithxamppInstalling configuringdevelopingwithxampp
Installing configuringdevelopingwithxampp
vimalnambiar
 
Ruby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybaraRuby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybara
Andolasoft Inc
 
Trigger Emails BigD17
Trigger Emails BigD17Trigger Emails BigD17
Trigger Emails BigD17
Susan McKenzie
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
MahmoudOHassouna
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
Sending Email with Rails
Sending Email with RailsSending Email with Rails
Sending Email with Rails
James Gray
 
10 Email Etc
10 Email Etc10 Email Etc
10 Email Etc
Geshan Manandhar
 
Using Parse Server to send emails via Mandrill
Using Parse Server to send emails via MandrillUsing Parse Server to send emails via Mandrill
Using Parse Server to send emails via Mandrill
Charles Ramos
 

Similar to Laravel mail example how to send an email using markdown template in laravel 8 (20)

Task scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorialTask scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorial
 
Node mailer example how to send email using nodemailer with gmail &amp; mailtrap
Node mailer example how to send email using nodemailer with gmail &amp; mailtrapNode mailer example how to send email using nodemailer with gmail &amp; mailtrap
Node mailer example how to send email using nodemailer with gmail &amp; mailtrap
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 
Action Mailer
Action MailerAction Mailer
Action Mailer
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdf
 
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
 
CICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your MindCICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your Mind
 
Object Oriented Programming With PHP 5 #2
Object Oriented Programming With PHP 5 #2Object Oriented Programming With PHP 5 #2
Object Oriented Programming With PHP 5 #2
 
Build Your Own Instagram Filters
Build Your Own Instagram FiltersBuild Your Own Instagram Filters
Build Your Own Instagram Filters
 
Ruby On Rails Starter Kit
Ruby On Rails Starter KitRuby On Rails Starter Kit
Ruby On Rails Starter Kit
 
How to add watermark to image using php
How to add watermark to image using phpHow to add watermark to image using php
How to add watermark to image using php
 
mush With Xampp
mush With Xamppmush With Xampp
mush With Xampp
 
Installing configuringdevelopingwithxampp
Installing configuringdevelopingwithxamppInstalling configuringdevelopingwithxampp
Installing configuringdevelopingwithxampp
 
Ruby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybaraRuby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybara
 
Trigger Emails BigD17
Trigger Emails BigD17Trigger Emails BigD17
Trigger Emails BigD17
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Sending Email with Rails
Sending Email with RailsSending Email with Rails
Sending Email with Rails
 
10 Email Etc
10 Email Etc10 Email Etc
10 Email Etc
 
Using Parse Server to send emails via Mandrill
Using Parse Server to send emails via MandrillUsing Parse Server to send emails via Mandrill
Using Parse Server to send emails via Mandrill
 

More from Katy Slemon

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
Katy Slemon
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
Katy Slemon
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdf
Katy Slemon
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdf
Katy Slemon
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdf
Katy Slemon
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
Katy Slemon
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdf
Katy Slemon
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Katy Slemon
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdf
Katy Slemon
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
Katy Slemon
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
Katy Slemon
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
Katy Slemon
 
New Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfNew Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdf
Katy Slemon
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
Katy Slemon
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Katy Slemon
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdf
Katy Slemon
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
Katy Slemon
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
Katy Slemon
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdf
Katy Slemon
 
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfUncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Katy Slemon
 

More from Katy Slemon (20)

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdf
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdf
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdf
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdf
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdf
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
 
New Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfNew Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdf
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdf
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdf
 
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfUncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
 

Recently uploaded

Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 

Recently uploaded (20)

Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 

Laravel mail example how to send an email using markdown template in laravel 8

  • 1. Laravel Mail Example: How to Send an Email using Markdown Template in Laravel 8? www.bacancytechnology.com
  • 2. Sending an email is one most important features of any project. In this tutorial, you will learn how to send emails using Markdown Template with the help of Laravel Mail Example. Implementation of the Markdown template is not a difficult task. Yes, you heard it correctly! But, still you haven’t played around it, here’s a step- by-step tutorial, that will provide you with instructions for sending an email using Markdown.
  • 3. CONTENTS Tutorial Goal: Laravel Mail Example using Markdown Template 1. 2. Step-by-step guidelines: Laravel Mail Example: How to Send an Email using Markdown Template in Laravel 8? 3. Conclusion
  • 5. Before diving into building a demo application, let’s see this video to clarify what we are building here. https://youtu.be/RXeAD0qOEB8 The user will enter the name and email address, and after clicking on submit button, an email will be sent to the entered email address. Login to that email address, and there you can see the email.
  • 6. Step-by-step guidelines: Laravel Mail Example: How to Send an Email using Markdown Template in Laravel 8?
  • 7. Step 1: Create Laravel Project composer create-project laravel/laravel -- prefer-dist BacancyEmail
  • 8. We are going to Set Mail Configuration here. For that, we will add our Gmail SMTP configuration such as name, password, etc. (Allow two-step verification and control access to less secure apps. in Gmail). We will use our .env file and add the configurations, which are described below. .env MAIL_MAILER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=prashantkhunt1999@gmail.com MAIL_PASSWORD= (third party app password <a href="https://support.google.com/accounts/answer/ 185833?hl=en" target="_blank">click hear</a>) MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=prashantkhunt1999@gmail .com MAIL_FROM_NAME="${APP_NAME}" Step 2: Configuration Setup.
  • 9. In this section, we will create Mailable Class with Markdown. A new Mailable class, which provides us to use Laravel event. It also provides the facility to re-use them anywhere in the application. For this, we will first create a class of Mailable, and for that, we will run the below artisan command- Step 3: Create Mail with Markdown php artisan make:mail BacancyMail -- markdown=emails.BacancyMail
  • 10. app/Mail/BacancyMail.php resources/views/emails/BacancyMail.bl ade.php By running the above command, two files are generated: Open the BacancyMail.php file in our app folder and then write the below code. app/Mail/BacancyMail.php <?php namespace AppMail; use IlluminateBusQueueable; use IlluminateContractsQueueShouldQueue; use IlluminateMailMailable; use IlluminateQueueSerializesModels;
  • 11. use Queueable, SerializesModels; public $body; /** * Create a new message instance. * * @return void */ public function __construct($body) { $this->body = $body; } /** * Build the message. * * @return $this */ public function build() { return $this->markdown('emails.BacancyMail')- >with('body',$this->body); } }
  • 12. Step 4: Create a Controller for Mail. In this step, we are going to create Controller Method. We will Create MailController as a new controller. Run the following command to create MailController. php artisan make:controller MailController Now we will use our MailController file and add the sendMail() function into it. Using this file, we can quickly write the mail send code, which is described as follows.
  • 13. <?php namespace AppHttpControllers; use AppMailBacancyMail; use IlluminateHttpRequest; use Mail; class MailController extends Controller { public function sendMail(Request $request) { $data = $request->validate([ 'name'=>'required', 'email'=>'required|email' ]); $email = $data['email']; $body = [ 'name'=>$data['name'], app/http/Controllers/MailController
  • 15. Step 5: Create a simple form Moving forward towards our Laravel Mail Example, now we will create one form in this step that takes the name and email from the user. Open resources/views/welcome.blade.php and add the below-mentioned code in the body section of the welcome page. resources/views/welcome.blade.php
  • 16. <body class="antialiased"> <div class="relative flex items-top justify-center min- h-screen bg-gray-100 dark:bg-gray-900 sm:items- center py-4 sm:pt-0"> <div class="max-w-6xl mx-auto sm:px-6 lg:px- 8"> @if (session('status')) <div class="alert alert-success"> {{ session('status') }} </div> @endif <div class="flex justify-center pt-8 sm:justify- start sm:pt-0"> <h1>Bacancy Technology Mail Sending Tutorials</h1> </div>
  • 17. <div class="mt-8 bg-white dark:bg-gray-800 overflow-hidden shadow sm:rounded-lg"> <div class="grid grid-cols-1 md:grid-cols-2"> <div class="p-6"> <div class="ml-12"> <form action="{{route('send.email')}}" method="POST"> @csrf <h6>Enter Name</h6> <input style="background:DarkGrey; width:500px; height:35px" type="text" name="name" value="" /> <br> <h6>Enter Email </h6> <input style="background:DarkGrey; width:500px; height:35px" type="email" name="email" id="email"> <br><br><br> <input class="btn btn-dark btn-block" type="submit" value="submit" name="submit"> </form> </div> </div> </div> </div> </div> </div> </body>
  • 18. The UI would be something like this-
  • 19. In step 3, we have created a blade file named BacancyMail.blade.php for an email template. This file will be useful to write the design code. We will add the below code into that file. resources/views/emails/BacancyMail.blade. php @component('mail::message') <h1>Hello {{$body['name']}},</h1> <p>The email is a sample email for Laravel Tutorial: How to Send an Email using Laravel 8 from @component('mail::button', ['url' => $body['url_a']]) Bacancy Technology @endcomponent</p> Step 6: Create Body for the Mail.
  • 20. <p>Visit @component('mail::button', ['url' => $body['url_b']]) Laravel Tutorials @endcomponent and learn more about the Laravel framework.</p> Happy coding!<br> Thanks,<br> {{ config('app.name') }}<br> Laravel Team. @endcomponent
  • 21. In this step, we are going to Create Route. We will create this for our testing mail. For this, we will use our web route file; go to the web.php file and define the following route. web.php Route::get('/', function () { return view('welcome'); }); Route::post('/sendBacancyMail', [MailController::class,'sendMail'])- >name('send.email'); Step 7: Define the Route.
  • 22. Now, finally we are done with out Laravel mail example. Run the project by using this command: php artisan serve. Step 8: Run the project Hit http://127.0.0.1:8000/, and you’ll see the user interface. Enter the name and email address; you’ll receive an e-mail on that email id. You can find the entire the source code here – Github Repository.
  • 24. So, this was a beginner’s guide on how to send email using the Markdown template in Laravel 8. Laravel Mail example was pretty straightforward, right? So, clone the github repository and start playing around with the code! I hope the Laravel Markdown email example was helpful to you. Visit Laravel Tutorial to explore more about Laravel. Bacancy Technology has dedicated and skilled Laravel developers. Are you looking for a Laravel expert? If yes, then without wasting a second, contact us and hire Laravel developer. We ensure to provide the best and proficient Laravel developers who can meet your requirements. Happy Coding!