简体   繁体   中英

How to validate Email for 'valid email' without sending 'email verfication' in laravel 8?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM