email-check
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?
function checkmail($address) {
$fp = fsockopen("localhost", 25, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$rset = 0;
$sender = "<>";
while (!feof($fp)) {
$regel = fgets($fp, 128);
if(substr($regel, 0, 3) == "250") {
if($action == "mail from") {
$out = "MAIL FROM:$sender\r\n";
$action = "rcpt to";
} else if($action == "rcpt to") {
$out = "RCPT TO:$address\r\n";
$action = "quit";
} else {
if($rset == 0) {
$status = TRUE;
} else {
$status = FALSE;
}
$out = "QUIT\r\n";
}
} else {
if(substr($regel, 0, 3) == "220") {
if($_POST[host] != "localhost") { $out = "HELO localhost\r\n"; }
else { $out = "HELO localhost\r\n"; }
$action = "mail from";
} else if(substr($regel, 0, 3) == "221") {
} else if(substr($regel, 0, 3) == "") {
} else {
if($rset == 0) {
$rset = 1;
$sender = "[email protected]";
$out = "RSET\r\n";
$action = "mail from";
} else {
$status = FALSE;
$out = "QUIT\r\n";
}
}
}
if(!empty($out)) {
fwrite($fp, $out);
$out = "";
}
}
fclose($fp);
}
return $status;
}
echo "<h4>e-mail Checker</h4>\n";
if(isset($_POST[submit])) {
echo "<table>\n";
echo "<form action=\"emailcheck.php\" method=\"POST\">\n";
echo " <tr>\n";
echo " <td colspan=\"2\">Controleren of een e-mail adress echt bestaat.</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>E-mail</td>\n";
echo " <td><input type=\"text\" name=\"email\" value=\"E-mailadres\" size=\"25\"><input type=\"submit\" name=\"submit\" value=\"Controleren\"></td>\n";
echo " </tr>\n";
echo "</form>\n";
echo "</table><br>\n";
if (checkmail($email) == 1 ) {
echo "<font color=\"green\">{$email}</font> bestaat.";
} else {
echo "<font color=\"red\">{$email}</font> bestaat niet.";
}
} else {
echo "<table>\n";
echo "<form action=\"emailcheck.php\" method=\"POST\">\n";
echo " <tr>\n";
echo " <td colspan=\"2\">Controleren of een e-mail adress echt bestaat.</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>E-mail</td>\n";
echo " <td><input type=\"text\" name=\"email\" size=\"25\"><input type=\"submit\" name=\"submit\" value=\"Controleren\"></td>\n";
echo " </tr>\n";
echo "</form>\n";
echo "</table>\n";
}
?>
function checkmail($address) {
$fp = fsockopen("localhost", 25, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$rset = 0;
$sender = "<>";
while (!feof($fp)) {
$regel = fgets($fp, 128);
if(substr($regel, 0, 3) == "250") {
if($action == "mail from") {
$out = "MAIL FROM:$sender\r\n";
$action = "rcpt to";
} else if($action == "rcpt to") {
$out = "RCPT TO:$address\r\n";
$action = "quit";
} else {
if($rset == 0) {
$status = TRUE;
} else {
$status = FALSE;
}
$out = "QUIT\r\n";
}
} else {
if(substr($regel, 0, 3) == "220") {
if($_POST[host] != "localhost") { $out = "HELO localhost\r\n"; }
else { $out = "HELO localhost\r\n"; }
$action = "mail from";
} else if(substr($regel, 0, 3) == "221") {
} else if(substr($regel, 0, 3) == "") {
} else {
if($rset == 0) {
$rset = 1;
$sender = "[email protected]";
$out = "RSET\r\n";
$action = "mail from";
} else {
$status = FALSE;
$out = "QUIT\r\n";
}
}
}
if(!empty($out)) {
fwrite($fp, $out);
$out = "";
}
}
fclose($fp);
}
return $status;
}
echo "<h4>e-mail Checker</h4>\n";
if(isset($_POST[submit])) {
echo "<table>\n";
echo "<form action=\"emailcheck.php\" method=\"POST\">\n";
echo " <tr>\n";
echo " <td colspan=\"2\">Controleren of een e-mail adress echt bestaat.</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>E-mail</td>\n";
echo " <td><input type=\"text\" name=\"email\" value=\"E-mailadres\" size=\"25\"><input type=\"submit\" name=\"submit\" value=\"Controleren\"></td>\n";
echo " </tr>\n";
echo "</form>\n";
echo "</table><br>\n";
if (checkmail($email) == 1 ) {
echo "<font color=\"green\">{$email}</font> bestaat.";
} else {
echo "<font color=\"red\">{$email}</font> bestaat niet.";
}
} else {
echo "<table>\n";
echo "<form action=\"emailcheck.php\" method=\"POST\">\n";
echo " <tr>\n";
echo " <td colspan=\"2\">Controleren of een e-mail adress echt bestaat.</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>E-mail</td>\n";
echo " <td><input type=\"text\" name=\"email\" size=\"25\"><input type=\"submit\" name=\"submit\" value=\"Controleren\"></td>\n";
echo " </tr>\n";
echo "</form>\n";
echo "</table>\n";
}
?>