@@ -41,13 +41,18 @@ public function isValidEmail($email) {
4141 public function isFreeEmail ($ email ) {
4242 if ($ email != '' ){
4343 $ result = $ this ->mbv ->isFreeEmail ($ email );
44- if ($ result != false && $ result ->error_code == '' ) {
45- if ($ result ->is_free == 'True ' ) {
46- return true ;
47- } else {
44+ if ($ result != false && (!property_exists ($ result , 'error ' )) ) {
45+ if (property_exists ($ result , 'is_free ' )) {
46+ if ($ result ->is_free ) {
47+ return true ;
48+ }
49+ } else {
4850 return false ;
4951 }
5052 } else {
53+ if (property_exists ($ result , 'error ' )) {
54+ throw new \Exception (__CLASS__ . ': ' . $ result ->error ->error_message , $ result ->error ->error_code );
55+ }
5156 // log_message('error', 'MBV API Error: ' . $result->error_code .'-' . $result->error_message);
5257 return false ;
5358 }
@@ -59,14 +64,19 @@ public function isFreeEmail($email) {
5964 public function isDisposableEmail ($ email ) {
6065 if ($ email != '' ){
6166 $ result = $ this ->mbv ->isDisposableEmail ($ email );
62- if ($ result != false && $ result ->error_code == '' ) {
63- if ($ result ->is_disposable == 'True ' ) {
64- return true ;
65- } else {
67+ if ($ result != false && (!property_exists ($ result , 'error ' )) ) {
68+ if (property_exists ($ result , 'is_disposable ' )) {
69+ if ($ result ->is_disposable ) {
70+ return true ;
71+ }
72+ } else {
6673 return false ;
6774 }
6875 } else {
6976 // log_message('error', 'MBV API Error: ' . $result->error_code .'-' . $result->error_message);
77+ if (property_exists ($ result , 'error ' )) {
78+ throw new \Exception (__CLASS__ . ': ' . $ result ->error ->error_message , $ result ->error ->error_code );
79+ }
7080 return false ;
7181 }
7282 } else {
0 commit comments