Home > Blockchain >  How to validate Email for 'valid email' without sending 'email verfication' in l
How to validate Email for 'valid email' without sending 'email verfication' in l

Time:04-27

I want to validate email as 'entered mail id valid or not' because user enters junk mail id it doesn't exist'

These are validation I have used

$request->validate([
            'name' => 'required',
            'email' => 'required|email|unique:users',
            'password' => 'required|min:6',
            'phone'  => 'required',
            'billing_address' => 'required',
            'billing_city' => 'required',
            'billing_state' => 'required',
            'billing_zipcode' => 'required',
            'billing_country' => 'required',
            'payment_gateway_id' => 'required',
        ],
        [
             'payment_gateway_id.required' => 'Please select payment gateway'
        ]);

my concern is user to enter valid mail address which is exists. I have used one package which is available https://github.com/tintnaingwinn/email-checker/issues/12 but is gives error for valid email address.

please help me to find the solution.

CodePudding user response:

You can't check that entered email address exist, but instead of that can add DNS validation. Laravel email validation rule uses the egulias/email-validator package with default option RFCValidation. You can add DNSCheckValidation like this.

$request->validate([
            'email' => 'required|email:rfc,dns|unique:users'
]);
DNSCheckValidation: Will check if there are DNS records that signal that the server accepts emails. This does not entail that the email exists.
  • Related