Skip to content

Conversation

@MdAnowarHosen
Copy link

We can now check valid email or not using Str::isEmail()

Here we used egulias/EmailValidator to check email validation.

We can check email with some rules.

  1. Strict
  2. Dns
  3. Spoof
  4. Filter
  5. Rfc

Str::isEmail() takes 2 parameters. first one is email we want to check and second one is rules we want to implement here. 2nd parameter is optional. By default it use Rfc rule to check email.

Here we just passed only one parameter, which check email using Rfc rule by default.

Example:

Str::isEmail('example@laravel.com')

Output: true


Str::isEmail('plainaddress')

Output: false


However, We can pass rules here like:

use Illuminate\Validation\Rules\EmailValidation;

Str::isEmail('example@laravel.com', EmailValidation::Rfc)

Output: true


use Illuminate\Validation\Rules\EmailValidation;

Str::isEmail('example.laravel.com', EmailValidation::Rfc)

Output: false


We can also use others rules.
Example:

use Illuminate\Validation\Rules\EmailValidation;

Str::isEmail('example@laravel.com', EmailValidation::Strict)

Output: true


use Illuminate\Validation\Rules\EmailValidation;

Str::isEmail('user@sub..domain.com', EmailValidation::Strict)

Output: false

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@MdAnowarHosen
Copy link
Author

I will be glad when my PR will be merge for first time. 😊 Thanks @taylorotwell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants