Laravel Tutorial: Send Emails Using Gmail SMTP - by Mailtrap

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to mail trap videos where we explore the world of emails today we'll teach you how to send emails in laravel using Gmail SMTP if you don't have a laravel project yet create it by running the composer create command you can find other installation methods and additional instructions in the official laravel documentation on the installation page we have already created a sample project so we can get straight to the configurations all the configurations for sending emails are located in the mail PHP file in the config directory in this file you'll find the configuration of the default mailer that will be used for sending emails laravel retrieves the value of the default mailer from mail mailer key in the end file if this value is missing then the default mailer will be used by going to the end file we can check the value of our mail mailer key as you can see it's set to SMTP let's go back to the mail PHP file here you can view the configuration details of each driver or specify your own default driver for example to use mail trap as your transport you should add it here and configure its parameters you can do the same for all supported drivers such as SMTP send mail and so on now it's time to start sending emails from laravel using Gmail SMTP for that we should first configure the sender in the end file set mail mailer key to SMTP the host to smtp.gmail.com and the port to 465. in the mail username field enter your Gmail email address it's necessary to generate the app password to configure the mail password key for that head over to your Gmail account and click manage your Google account button go to the security Tab and turn two-step verification on you'll see a green check mark after the successful activation click on the two-step verification menu enter the password if prompted and scroll down find app passwords at the very bottom of the page and click on it in the selected app field choose mail and pick other custom name in the selected device field enter the desired name of your app password click generate and your app password will appear on the screen copy the password and click done go to your laravel project and paste the password in the mail password key set the encryption to TLS and specify the sender with the email address indicated as the username we'll leave the default value in the mail from namekey once all the configurations are completed we can start generating the mailable class run make mail Artisan command the command will return the route from the mailable class and the message indicating successful execution this class will be stored in the app mail directory the newly created files show that the mail class was generated with all the parameters needed for sending emails next go to webphp file located in The Roots directory and enter the new route in our example we've already configured the new route we'll be sending emails to the indicated email address but you can enter any address you want to specify the name of the recipient it's necessary to write a new name parameter in the Constructor and in the content method pass the name to view we should also configure the name of The View our view is located in the mail file in the resource directory so the name of the view in this case will be mail but we also have to indicate the name of the template which is test email in our example the template is very simple we're sending a plain text email with the name variable now we can go to the root and send an email let's open our test route and check our inbox there you go the email is right there that's all we have for you today feel free to check out our article to learn more about sending emails in laravel with Gmail SMTP where we also cover alternatives to Gmail SMTP all the links will be available in the description below we hope you found this tutorial helpful thank you for watching this video brought to you by mailtrap an email delivery platform to test send and control your email infrastructure in one place like and share this video And subscribe to our channel to see more tutorials like this one don't forget to check out our other videos for more useful content on email deliverability see you in the next one foreign [Music]
Info
Channel: Mailtrap
Views: 2,424
Rating: undefined out of 5
Keywords: Mailtrap, mailtrap.io, mailtrap tutorial, laravel mailtrap, laravel send email with gmail, laravel 8 send email gmail, laravel send email smtp gmail, gmail configuration, gmail smtp settings, laravel env, mail_host gmail, laravel gmail smtp, laravel gmail, laravel send email using gmail, php tutorial, laravel tutorial, laravel project, laravel gmail integration, laravel gmail api, laravel gmail login, php laravel tutorial for beginners, php laravel, laravel 10
Id: JesSP3pRB_I
Channel Id: undefined
Length: 5min 1sec (301 seconds)
Published: Fri Aug 18 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.