Validating and verifying email addresses in PHP

  Рет қаралды 25,250

Dave Hollingworth

Dave Hollingworth

Күн бұрын

email validation API: ► davehollingworth.com/go/email...
PHP for Beginners course: ➤ davehollingworth.net/phpy
PHP MVC course: ► davehollingworth.net/phpmvcy
CodeIgniter 4 course: ► davehollingworth.net/codeigni...
Often in a PHP web application or website we need a user to provide an email address, for example when they sign up for an account, fill in an order form and so on. How do we make sure the user has entered a valid email address using PHP? One that's a valid format, but also one that isn't fake?
In addition to checking the format, email verification checks whether an email address is accurate, valid, and deliverable. We can check for disposable email addresses, free email addresses and more.
Verifying email addresses will make sure emails you send out will avoid spam filters and keep bounce rates low.
Resources:
www.php.net/manual/en/functio...
www.php.net/manual/en/book.cu...
www.abstractapi.com/email-ver...
Code shown in the video:
gist.github.com/daveh/833577a...
00:00 Introduction
00:58 Validate format
03:00 email validation API
08:26 Examples
10:04 Summary
#PHP #email #API

Пікірлер: 45
@NedumEze
@NedumEze 3 жыл бұрын
Wow! How helpful! And far simpler and smaller than the one I, which has to send a test mail to surfer to validate, which he cannot do, if address is fake. Thanks again, Dave
@ignaciomontali
@ignaciomontali 2 жыл бұрын
Great tutorials! Ive seen a few and the rythm simplifies the content plus the organization and the step by step progress! Thank you very much! I´m Already subscribed!
@antonioserafimovski7398
@antonioserafimovski7398 3 жыл бұрын
You are awesome man i learned so much from ur videos thanks a lot!
@jooryalhamed938
@jooryalhamed938 2 жыл бұрын
Many thanks, this has worked perfectly!
@saviorpascal6323
@saviorpascal6323 2 жыл бұрын
a very big thank you to you for helping me solve one of yet my biggest problem
@nbvdib2098
@nbvdib2098 2 жыл бұрын
thx man, you just saved me in 1:52 minutes
@RagHelen
@RagHelen 2 жыл бұрын
I am tempted to try this service with a fresh address, just to see, if I get any spam after that :) But the video is very nice to watch.
@IBeThieving
@IBeThieving 3 жыл бұрын
One other thing I like to do is validate the existence of the email address domain by sending a request to that domain. This reduces strain on the database should a user use a fake email and also allows you to not rely on 3rd party API’s more of an in house solution to reduce costs. Great video though!
@dave-hollingworth
@dave-hollingworth 3 жыл бұрын
Totally agree - when I do a registration site, I require users to confirm their email address by sending them a unique token contained in a URL, denying them login until they have confirmed the email address. Glad you like the video!
@IBeThieving
@IBeThieving 3 жыл бұрын
@@dave-hollingworth Absolutely combining the two creates a very robust solution.
@NedumEze
@NedumEze Жыл бұрын
Could you share the code you use to query the domain here, please?
@danieligbinidu6880
@danieligbinidu6880 Жыл бұрын
Thanks alot for help
@abujoha1555
@abujoha1555 Жыл бұрын
Nice Brother.
@DavidAshby1
@DavidAshby1 Жыл бұрын
Great video. I have been doing a little research regarding email addresses and sanitization as well as validation. As usual, there are a variety of opinions regarding email addresses. Some say, sanitize the email address before you do anything else with it, some say validate before sanitize. Keeping in mind, if the field is required, and html5 automatically looks for a correct format and then getting the end user to verify their account, as I think you mention in a reply below, before they can log in and then have a script that scrubs the database of unverified accounts after, say 24hrs, is that enough or would you recommend a 3rd party API to also check the email address does actually exist?
@dave-hollingworth
@dave-hollingworth Жыл бұрын
It depends on how much work you want your script to do - if you use a third-party API to check that the email address actually exists, then you'll save yourself trying to send an email to a non-existent address (something you might want if you're paying for the number of emails you send)
@DavidAshby1
@DavidAshby1 Жыл бұрын
@@dave-hollingworth Trying to identify role email addresses but no matter what I do it does not identify them. I have elseif($data['is_role_email'] === true){ echo "Role Email"; } This is a continuation from your code. I am assuming that the code I have written here is wrong but unsure. Could you possibly advise? Thanks
@DavidAshby1
@DavidAshby1 Жыл бұрын
Think I have it if($data['is_role_email']["value"] === false){ echo "Role Email"; }
@akhwatjomblochannel789
@akhwatjomblochannel789 Жыл бұрын
can i use password gmail from API ? what solution ? thanks
@deepatripathi7829
@deepatripathi7829 2 жыл бұрын
thank you
@ramsesramos1151
@ramsesramos1151 Жыл бұрын
It works! thank you so much Dave!, a noob question.. how can i display the result messages on top of the input inside form.html instead of them showing on the validate_email.php? again thank you so much
@dave-hollingworth
@dave-hollingworth Жыл бұрын
You'd have to either redirect back to the original page, passing the error message back to that page somehow - for example in the query string or in the session. Alternatively you could process the submitted form in the same script as the HTML at the top, then redisplay the form if there are errors.
@jamestrey3049
@jamestrey3049 7 ай бұрын
excuse me! Can I use justValidation as the script language to display the api email result in the html file or need Ajax to process them? is there any solution that no need to get the next page to verify mail log up? please help me
@dave-hollingworth
@dave-hollingworth 7 ай бұрын
Yes, if you want to use Ajax to get the result of validating the email on the server, that's no problem
@jamestrey3049
@jamestrey3049 7 ай бұрын
@@dave-hollingworth tks sir
@jamestrey3049
@jamestrey3049 7 ай бұрын
@@dave-hollingworth How can I use JustValidate to display them sir
@dave-hollingworth
@dave-hollingworth 7 ай бұрын
@@jamestrey3049 Check out this example in the documentation: just-validate.dev/examples#async-validation
@jamestrey3049
@jamestrey3049 7 ай бұрын
Thanks Dave!@@dave-hollingworth I also have a question How to create email register in the log up
@sheriwatson9055
@sheriwatson9055 2 жыл бұрын
I've tried this and it's not working quite right. I copied and pasted the code into the appropriate files. The html works fine. I can input a real working email and the page is returned blank. I'm not getting the data dump. I included the $var_dump($data); line and it is still not working.
@dave-hollingworth
@dave-hollingworth 2 жыл бұрын
A blank screen usually means an error is occurring, but PHP isn't configured to display them. Try adding these lines to the top of your script: ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL);
@penaldocubeg9516
@penaldocubeg9516 8 ай бұрын
It is showing the .php page code when I entered a valid email. Not getting the output please help
@victorpaulson5712
@victorpaulson5712 9 ай бұрын
Great video! How can check up to 10 emails at once without having to input them one after the other ? Thanks
@dave-hollingworth
@dave-hollingworth 9 ай бұрын
If you put them in an array you can loop around that array and check each one at once
@victorpaulson5712
@victorpaulson5712 9 ай бұрын
@@dave-hollingworth Thanks. Well I successfully typed in both the html code and php code but I got this error.. Warning: Undefined array key “deliverability” Warning: Undefined array key “is_disposable_email” Warning: Trying to access array offset on value of type null
@dave-hollingworth
@dave-hollingworth 9 ай бұрын
@@victorpaulson5712 Without seeing the code that these error messages refer to, it's a bit difficult to debug - try posting the relevant code snippet here or in pastebin or somewhere similar
@victorpaulson5712
@victorpaulson5712 9 ай бұрын
@@dave-hollingworth do you mean I should post the full codes here or what, I’m sorry I didn’t really get what you meant. Also I think I got lost in the video when you brought it the Curl part, I didn’t really understand what you did there 🤷🏼‍♂️ could it be because I didn’t use the Curl ?
@dave-hollingworth
@dave-hollingworth 9 ай бұрын
@@victorpaulson5712 Yes, I meant post the code that's causing the error so I can see if I can spot the problem. It could be because you're not using cURL but it's not clear from the error message.
@malikzain601
@malikzain601 2 жыл бұрын
How many bulk emails we can valid in an hour?
@dave-hollingworth
@dave-hollingworth 2 жыл бұрын
www.abstractapi.com/email-verification-validation-api#pricing
@kraleemil
@kraleemil 2 жыл бұрын
79 i think
@AbdulAlim-gv1gs
@AbdulAlim-gv1gs Жыл бұрын
Hello, what is your contact email?
@dave-hollingworth
@dave-hollingworth Жыл бұрын
davehollingworth.com/contact
@AbdulAlim-gv1gs
@AbdulAlim-gv1gs Жыл бұрын
@@dave-hollingworth please check your email. I contacted
Working Contact Form in PHP with Validation & Email Sending
22:55
FollowAndrew
Рет қаралды 182 М.
I PEELED OFF THE CARDBOARD WATERMELON!#asmr
00:56
HAYATAKU はやたく
Рет қаралды 37 МЛН
格斗裁判暴力执法!#fighting #shorts
00:15
武林之巅
Рет қаралды 65 МЛН
100❤️
00:19
Nonomen ノノメン
Рет қаралды 26 МЛН
Using PHPMailer sending OTP Code & Password Reset using PHP
10:16
CodeCreative
Рет қаралды 30 М.
Perfect way to Validate Email ID using PHP | PHP Email ID DNS Validation
9:23
Programming with Vishal
Рет қаралды 6 М.
Incognito Market Owner Arrested
9:13
Seytonic
Рет қаралды 120 М.
PHP and MySQL with CRUD Operations: Create, Read, Update, Delete
32:49
Wow AirPods
0:17
ARGEN
Рет қаралды 1,1 МЛН
3D printed Nintendo Switch Game Carousel
0:14
Bambu Lab
Рет қаралды 4,4 МЛН
Which Phone Unlock Code Will You Choose? 🤔️
0:14
Game9bit
Рет қаралды 11 МЛН