Laravel Email Verification - A Step-By-Step Tutorial by Mailtrap

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to mail track videos where we explore the world of emails here's how to do email verification in laravel for the purpose of this video we'll be using a sample laravel project as well as mailtrap email sending credentials for SMTP to access the SMTP settings you first need to create a mailtrap account add a sending domain and verify it then navigate to the sending domains and copy the SMTP settings in the API and SMTP tab open the laravel project and in the EnV file fill in the necessary lines with the mailtrap credentials you copied before apart from setting up the emails you should also configure the database Connection in our case the configuration includes the host default MySQL Port database name username and password then you should run the PHP Artisan migrate command so that the necessary tables appear in the database next scaffold the UI to generate login registration and forgot password pages in this video we'll be using the laravel breeze package it's a basic starter kit with authentication features and a user profile page for updating personal information you'll find the link to the official laravel documentation in the description of this video to install the package run the composer require command after the installation laravel Breeze should also appear in your composer Json file in the dev section you can use laravel Breeze in combination with various front-end Technologies such as blade templates vue.js or the react framework run Breeze install command to publish the code to your application then install front-end dependencies and libraries with npm install command and run them with npm run Dev at this point you can already go to your sites page our page looks like this as you can see after we installed laravel Breeze log in forgot password and register Pages appeared now we can move on to enabling the email verification feature itself you need to go to model user and add must verify email contract and run the migrate command once again go to the users table the email verified at field should appear there it's time to open webphp in Roots and add three routes that handle email verification email verify email verify ID hash and email verification notification remember that these routes should have the following names exactly verification notice verification verify and verification send in the file you can find laravel routes for you to access to the profile dashboard and home page after performing all of these actions go to your site and register to see if the email verification feature is working correctly let's register using an email and password and then click register we see a message asking us to verify the email let's go to our inbox and check if an email from La Ravel has arrived voila it's right there until we click on the verify email address the email verified at field in our database will be empty but as soon as we click on the button laravel will immediately log us into the dashboard page and if we check our database once more the email verified at field will now contain the date and time of verification now the user can successfully access the dashboard and profile Pages which are only available to verified users all right let's move on to customizations laravel allows you to customize the sender name subject line the text on the button and the contents of your verification emails let's start by customizing the sender name which is laravel by default to change it go to the EnV file in the app name value change laravel to your desired name after that you'll start receiving emails with the customized sender name to customize other values go to the provider's directory and open the auth service provider file here you should configure the two mail using method in the boot method of your app the two mail using method accepts the function that should return the necessary configuration this way you can modify the subject line body text and the text on the button with the URL parameter finally laravel also allows you to verify users manually without sending the emails this is necessary when we need to add system users that don't have accessible email addresses or migrate verified email lists to the laravel project we'll explain several ways of manual verification you'll need to make changes in the controller file here we created a sample controller in the controller's directory the first way to verify users manually is to use the mark email as verified method with this method the email address will be verified when the user creates an account so let's create a username John with a sample email address and hash of a password keep in mind that the user won't be verified after creation unless you call the mark email as verified method this method will also fill in the user's table in the database and the user will be verified another way to verify users manually is to add the email verified at field with the current date while creating the user parameter this time you'll need to use the force create method instead of the one we used previously by doing so laravel will allow you to change the value of the email verified at field third way to verify users manually is to change the fillable property in the user model you'll just have to add the field that is responsible for user verification use the create method again to indicate explicitly that you want to change this field with these three methods you can easily verify users manually in laravel and that's all we have for you today we at mailtrap 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 step-by-step tutorials see you in the next video [Music] thank you [Music]
Info
Channel: Mailtrap
Views: 3,983
Rating: undefined out of 5
Keywords: Mailtrap, mailtrap tutorial, laravel mailtrap, mailtrap.io, laravel, laravel tutorial, laravel api, email verification, laravel tutorial youtube, learn laravel for beginners, laravel email verification, smtp, api, laravel verify email, php, php laravel, custom verify email laravel, verify email auth laravel, email verify laravel, email verification with mailtrap laravel 10, web development, enable verify email laravel, laravel 10 create email verification system, laravel project
Id: KiHzbVsErNo
Channel Id: undefined
Length: 6min 41sec (401 seconds)
Published: Mon Jun 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.