⚡Laravel 10 Contact Form |How to Send Email in Laravel using Gmail |Laravel Contact Form send Email

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello guys welcome to my YouTube channel if you are new to my Channel please subscribe to my channel like this video and press the Bell icon in this video I will show you how to create a contact form in laravel and send email using Gmail so let's get started to install laravel open your terminal now type laravel new your project name and press enter it will take some time to download depending on your internet connection so wait for the download to get complete deleted the download is completed successfully now type CD your project name to go to the project directory now open your project into your editor here I am using VSS code so I will open my project into vs code now open. EnV file now copy the database name we will create a database with the same name now go to your browser and open PHP my admin now create a database with the same name which you have copied from Dov file now type PHP artisan make colon controller contact controller to create the contact controller we will create show method to display the contact for form now we will add a root for the show method in the web.php file don't forget to import contact controller else you will get an error now open resources viws folder and create a blade file called contact. blade. PHP now we will add Tailwind CSS CDN copy the CDN paste the CDN after the title tag now for the contact form open tailblock docc website copy this contact form now paste the contact form code in side body tag add form tag here now cut this code and paste inside the form tag remove this unnecessary code now add type equal submit in button tag change button text to send now type PHP P Artisan serve to run our app in your browser type Local Host colon 8000 and press enter you will see the welcome page now type SL contact after Local Host col 8000 and you will see the contact us page to send mail using laravel we need to create a mailable class we will use markdown mailable Class Type PHP Artisan makeon mail contact us markdown equals emails. contact this command will create a contact us mailable class inside mail folder and contact. blade. PHP markdown file inside resources view/ emails folder this is contact us mailable class this is contact. blade. PHP markdown template here type from colon new address in parenthesis type the email address from which you want to send the email don't forget to import address type public dollar data we will use dollar data to get name email and message from the contact us for form the construct method takes dollar data as a parameter type dollar this Arrow data equals dollar data it will assign the value of the dollar data parameter passed to the Constructor to an instance variable called dollar data within the class open contact controller we will create send method to send the mail first we will validate the inputs and store them in the dollar data variable the dollar data will be passed with the contact us mailable class now to send the mail with the input details we will use the to method on the mail facade add the email address on which you want to receive the email now pass an instance of your mailable class to the send method now we will add post rot for the send method add root name inside the form tag also add the csrf method now add following code in the contact. blade. PHP markdown template to pass the contact from data into the mail first we will use mail trap for sending email so open mail trap website log in using your email and password click on show credentials to see your mail trap username and password now in the EnV file type your mail trap username and password and other details we forgot to add the post method in contact form so add method equals Post in the form tag reload the contact us page now enter name email and message and click on the send button to send the mail you can see that the page is loading which indicates that the email is being sent sent is displayed it means that the mail has been sent successfully open mail trap inbox and you will see the mail which you have sent you can see the mail with name email and message now we will redirect back to the contact page after the mail has been sent and show the success message now for the success message open PHP no.in and search for Livewire 3 crud tutorial copy this code now open cont contact. blade. PHP file and paste the code before the form tag reload the contact us page type name email and message and click on send button you can see the success message is displayed now open mail trap inbox and you will see the mail which you have sent recently now we will display validation messages so that when the user tries to submit an empty form error messages will be displayed reload the contact us page now click on send button without entering data in the form and you will see error messages now to send email using Gmail open your Gmail account now click on your profile picture and then click on manage your Google account now click on security scroll down and click on two-step verification click on get started enter your password and click on next here enter your mobile number and click on next and you will receive a code from Google on your mobile number now type the code which you have received and click on next now click on turn on to turn on two-step verification scroll down and you will see green check on two-step verification click on it scroll down and you will see app passwords in the bottom click on it type your app name and click on create you will see a popup displaying 16 digits generated app password copy this app password paste it in a text file and click on done now open. EnV file and add the Gmail SMTP details as shown in the code in the username type the Gmail ID from which you want to send email in the password type the 16 digits app password which you have copied remove the spaces from your app password now open mail.php file and add the code inside SMTP section now open contact controller file and add the mail ID on which you want to send emails now open contact us mailable file and in the envelope method add the Gmail ID which you have added in the MV file reload the contact us page type name email and message and click on send button you can see that the page is loading which indicates that the email is being sent you can see the success message is displayed we will send another mail so reload the page and type name email message and click on send button to send the mail you can see the success message which indicates that the mail has been sent now open the mailbox of your email account which you have entered inside contact controller to Method you can see the mail which we have sent you using the contact us page let's send the mail one more time reload the page type name email message and click on send button you can see the success message which indicates that the mail has been sent now open your mailbox and you will see the mail in your inbox with name email and message here is the mail which we have sent recently thanks for watching please like share and subscribe to my channel I will see you in next tutorial till then stay safe
Info
Channel: Php Node Tuts
Views: 3,020
Rating: undefined out of 5
Keywords: laravel contact form send email, send email in laravel, laravel 10 send email, laravel send email, laravel email send, how to send email in laravel, laravel tutorial, Laravel 10 Tutorial, laravel contact form, laravel contact page, laravel 9 contact form, laravel 10 contact form, laravel send mail using gmail, laravel send mail example, laravel send mail with smtp, php mailer script with smtp, laravel project, laravel mail
Id: GSIUAhmn9ks
Channel Id: undefined
Length: 29min 22sec (1762 seconds)
Published: Tue Nov 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.