Skip to content

Commit 1fee6bf

Browse files
Update to use v2 API.
1 parent 21c52dc commit 1fee6bf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ValidateEmail.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function GetValidateDisposable($email,$api_key) {
1212
$source = 'laravel';
1313
try {
1414
// Now we need to send the data to MBV API Key and return back the result.
15-
$results = file_get_contents('https://api.mailboxvalidator.com/v1/email/disposable?key=' . $api_key . '&email=' .$email. '&source=' .$source );
15+
$results = file_get_contents('https://api.mailboxvalidator.com/v2/email/disposable?key=' . $api_key . '&email=' .$email. '&source=' .$source );
1616

1717
if ($results == false) {
1818
return 'Unknown error encounter. Please try again later.';
@@ -37,21 +37,21 @@ function ValidateDisposable($attribute, $value, $parameters, $validator) {
3737
$source = 'laravel';
3838
try {
3939
// Now we need to send the data to MBV API Key and return back the result.
40-
$results = file_get_contents('https://api.mailboxvalidator.com/v1/email/disposable?key=' . $api_key . '&email=' .$value. '&source=' .$source );
40+
$results = file_get_contents('https://api.mailboxvalidator.com/v2/email/disposable?key=' . $api_key . '&email=' .$value. '&source=' .$source );
4141

4242
// Decode the return json results and return the data as an array.
4343
$data = json_decode($results,true);
4444

4545
// Called a function to return message for form validation
46-
if (trim ($data['error_code']) == '' ) {
47-
if ( $data['is_disposable'] == 'True' ) {
46+
if (! array_key_exists('error', $data)) {
47+
if ( $data['is_disposable']) {
4848
// $errorMessage = 'The email '.$value.' is disposable email and should not been used to register.';
4949
return false;
5050
} else {
5151
return true;
5252
}
5353
} else {
54-
return $data['error_code'] . $data['error_message'];
54+
return $data['error']['error_code'] . $data['error']['error_message'];
5555
}
5656

5757
} catch (Exception $e) {

0 commit comments

Comments
 (0)