summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Battat <hbattat@msn.com>2014-03-08 01:13:53 -0600
committerSam Battat <hbattat@msn.com>2014-03-08 01:13:53 -0600
commit1d6b452665d64c97fca738a09a27e9a6e2930125 (patch)
treec855a144ec38871d842a057550f03d1d4d557224
parent030c8772492824b55467cb05e9960ff7613d130a (diff)
downloadverifyEmail-1d6b452665d64c97fca738a09a27e9a6e2930125.zip
verifyEmail-1d6b452665d64c97fca738a09a27e9a6e2930125.tar.gz
verifyEmail-1d6b452665d64c97fca738a09a27e9a6e2930125.tar.bz2
Added function file
-rw-r--r--verify.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/verify.php b/verify.php
new file mode 100644
index 0000000..b609c5f
--- /dev/null
+++ b/verify.php
@@ -0,0 +1,47 @@
+<?php
+print_r(verifyEmail('dsfdsfdasdsadasdasds@gmail.com', 'root@w3ing.tk', true));
+
+function verifyEmail($toemail, $fromemail, $getdetails = false){
+ $email_arr = explode("@", $toemail);
+ $domain = $email_arr[1];
+ getmxrr($domain, $mxhosts, $mxweight);
+ $mx = $mxhosts[array_search(min($mxweight), $mxhosts)];
+
+ $connect = @fsockopen($mx, 25);
+ if($connect){
+ if(ereg("^220", $out = fgets($connect, 1024))){
+ fputs ($connect , "HELO $HTTP_HOST\r\n");
+ $out = fgets ($connect, 1024);
+ $details .= $out."\n";
+
+ fputs ($connect , "MAIL FROM: <$fromemail>\r\n");
+ $from = fgets ($connect, 1024);
+ $details .= $from."\n";
+
+ fputs ($connect , "RCPT TO: <$toemail>\r\n");
+ $to = fgets ($connect, 1024);
+ $details .= $to."\n";
+
+ fputs ($connect , "QUIT");
+ fclose($connect);
+
+ if(!ereg("^250", $from) || !ereg("^250", $to)){
+ $result = "invalid";
+ }
+ else{
+ $result = "valid";
+ }
+ }
+ }
+ else{
+ $result = "invalid";
+ $details .= "Could not connect to server";
+ }
+ if($getdetails){
+ return array($result, $details);
+ }
+ else{
+ return $result;
+ }
+}
+?>