Skip to content

Commit b653d9b

Browse files
authored
Merge pull request #4 from iamfaysal/master
Mailbox Verification added to return accurate validation result
2 parents 03f6a25 + d7f3471 commit b653d9b

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

README.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,17 @@ Example Use Case
3131

3232
echo var_dump($validator->validateExtended('someuser@ymail.com'));
3333

34-
// object(stdClass)#2 (4) {
35-
// ["address"]=>
36-
// string(19) "someuser@ymail.com"
37-
// ["did_you_mean"]=>
38-
// NULL
39-
// ["is_valid"]=>
40-
// bool(true)
41-
// ["parts"]=>
42-
// object(stdClass)#4 (3) {
43-
// ["display_name"]=>
44-
// NULL
45-
// ["domain"]=>
46-
// string(10) "ymail.com"
47-
// ["local_part"]=>
48-
// string(8) "someuser"
49-
// }
50-
// }
34+
object(stdClass)#207 (8) {
35+
["address"]=> string(18) "someuser@ymail.com"
36+
["did_you_mean"]=> NULL
37+
["is_disposable_address"]=> bool(false)
38+
["is_role_address"]=> bool(false)
39+
["is_valid"]=> bool(true)
40+
["mailbox_verification"]=> string(4) "true"
41+
["parts"]=> object(stdClass)#208 (3) {
42+
["display_name"]=> NULL
43+
["domain"]=> string(9) "ymail.com"
44+
["local_part"]=> string(8) "someuser"
45+
}
46+
["reason"]=> NULL
47+
}

src/MailgunValidator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private function queryMailgun($email)
3131
$curl = curl_init();
3232

3333
curl_setopt_array($curl, array(
34-
CURLOPT_URL => self::API_ENDPOINT . "?api_key=" . $this->apiKey . "&address=" . urlencode($email),
34+
CURLOPT_URL => self::API_ENDPOINT . "?api_key=" . $this->apiKey . "&address=" . urlencode($email) . '&mailbox_verification=true',
3535
CURLOPT_RETURNTRANSFER => true,
3636
CURLOPT_MAXREDIRS => 0,
3737
CURLOPT_TIMEOUT => 30,
@@ -58,7 +58,7 @@ private function queryMailgun($email)
5858
public function validate($email)
5959
{
6060
$ret = $this->queryMailgun($email);
61-
return $ret->is_valid;
61+
return $ret->is_valid === true && $ret->mailbox_verification !== false;
6262
}
6363

6464
/**

0 commit comments

Comments
 (0)