Simple Way To Send Email via Gmail SMTP In Laravel

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends in this video we are going to see simple way for sending email with gmail smtp in laravel 8. let's get started [Music] first thing you have to do is to allow your gmail account for sending email just click on on manage your account button click on security link then scroll down and find less secure app access section as you can see my account less secure is off to turn on click on this blue link then change this toggle button position to blue color as you can see the less secure access turned on automatically google send notification about this updates so let's continue back to your louravelleproject.n file and update your mail variables after updating this save the file open terminal and run php artisan serve command for running your application as you can see we are on laravel 8. create new controller and rename to contact controller as you can see our controller has been created go to web php file and import contact controller into it create new route view for contact form let's create this view as you can see we have this contact page let's design this page layout with bootstrap just link bootstrap on this page now design this page with bootstrap classes this form will contains name email subject and message input fields as you can see we have now contact form on this page create post route for sending email let's use this route name to our contact form action attribute don't forget to add csrf on this form add send method inside contact controller class validate your form first name must be required email must be required and be in email format subject must be required message must be required let's see if validation works as you can see our validation works perfectly let's continue sending email will require an internet connection that is why we must check if we are connected on internet or not let's write this function for check internet connectivity let's check if i fill all required inputs and submit this form when i connect it to internet i get this message that shows me that i am connected to the internet but if i submit this form when i am not connected to internet i get this message that shows that i am offline let's continue if we are not connected to internet redirected back to contact form with error message but when we have an internet connection send email to a given recipient if email sent successfully redirect back with success message let's create this email template blade file inside this blade we pass body variable let's test fill sender details in this form then click send as you can see we don't have any error let's check if email sent to that email address as you can see we received new email from dussen now let's show error or success alert here we have this success alert here you can receive responsive html email body here instead of this plain text let's see how you can implement that i already have this html email template we are going to send this html email example just copy this html markup and paste inside this email template blade file replace this with body variable let's test send new email as you can see i received a new email from doe and also is a responsive email friends that is how you can send emails by using gmail smtp and laravel thanks for watching this video
Info
Channel: Irebe Library
Views: 735
Rating: undefined out of 5
Keywords: irebe library, laravel 8, gmail, gmail smtp, sending email, send email, send email in laravel
Id: CYzqw3gHhJ0
Channel Id: undefined
Length: 16min 6sec (966 seconds)
Published: Tue Nov 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.