Skip to content

Commit 388c0e5

Browse files
Update ValidateEmail.php
1 parent 1659130 commit 388c0e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ValidateEmail.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ function GetValidateDisposable($email,$api_key) {
2828
}
2929

3030

31-
function ValidateDisposable($email) {
31+
// $value holds the email address from the form.
32+
function ValidateDisposable($attribute, $value, $parameters, $validator) {
3233
if (!isset($api_key)) {
3334
$api_key = env('MBV_API_KEY');
3435
}
3536
$source = 'laravel';
3637
try {
3738
// Now we need to send the data to MBV API Key and return back the result.
38-
$results = file_get_contents('https://api.mailboxvalidator.com/v1/email/disposable?key=' . $api_key . '&email=' .$email. '&source=' .$source );
39+
$results = file_get_contents('https://api.mailboxvalidator.com/v1/email/disposable?key=' . $api_key . '&email=' .$value. '&source=' .$source );
3940

4041
// Decode the return json results and return the data as an array.
4142
$data = json_decode($results,true);
4243

4344
// Called a function to return message for form validation
4445
if (trim ($data['error_code']) == '' ) {
4546
if ( $data['is_disposable'] == true ) {
46-
$errorMessage = 'The email '.$email.' is disposable email and should not been used to register.';
47+
$errorMessage = 'The email '.$value.' is disposable email and should not been used to register.';
4748
return false;
4849
} else {
4950
return true;

0 commit comments

Comments
 (0)