Apply DNS and RFC Validation to Emails in Laravel

Updated 2 weeks ago admin PHP / Laravel

In this lesson, we will see how to apply DNS and RFC validation to emails in Laravel. The default email validator does not check for the presence of the domain and can detect this string 'test@gmail' as a valid email even though the string does not contain a domain.

Solving the problem

Laravel offers a DNS validator to solve this kind of problem. All you need to do is validate the email address using the code below:

'email' => 'email:rfc,dns'