-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesthost.php
More file actions
81 lines (61 loc) · 2.03 KB
/
testhost.php
File metadata and controls
81 lines (61 loc) · 2.03 KB
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
<?php
//------------ SETTINGS ------------
$helo = $_SERVER ['HTTP_HOST'];
$from = "info@mail.com";
$scriptpass = "E35DCBD20CC0";
//------------ END SETTINGS ------------
$email = $_GET ["email"];
$password = $_GET ["password"];
if ($password != $scriptpass) {
echo "<check>96DA8A550749</check><server>Verify Script</server><message>603 Wrong Password</message><log></log>";
return;
}
$result = Test ( $email, $from, $helo );
echo "<check>96DA8A550749</check><server>" . $result [1] . "</server><message>" . $result [0] . "</message><log>" . $result [2] . "</log>";
// Function result results in an array:
// $result[0] - SMTP Server Replay
// $result[1] - SMTP Server Host
// $result[2] - SMTP Server Log
function Test($Email, $From, $Helo) {
$result = array ();
if (! eregi ( "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $Email )) {
$result [0] = "500 Bad Syntax";
return $result;
}
list ( $Username, $Domain ) = split ( "@", $Email );
if (checkdnsrr ( $Domain, "MX" )) {
$log .= "MX record about {$Domain} exists:\r";
if (getmxrr ( $Domain, $MXHost )) {
//for ( $i = 0,$j = 1; $i < count ( $MXHost ); $i++,$j++ )
//{
// $log .= "$MXHost[$i]\r";
//}
}
$ConnectAddress = $MXHost [0];
$log .= $ConnectAddress . "\r";
} else {
$ConnectAddress = $Domain;
$log .= "MX record about {$Domain} does not exist.\r";
}
$Connect = fsockopen ( $ConnectAddress, 25 );
$result [1] = $ConnectAddress;
// Success in socket connection
if ($Connect) {
$log .= "Connection succeeded to {$ConnectAddress} SMTP.\r";
$reply = fgets ( $Connect, 1024 );
$log .= $reply."\r";
// Finish connection.
fputs ( $Connect, "QUIT\r\n" );
$log .= "> QUIT\r";
fclose ( $Connect );
} // Failure in socket connection
else {
$result [0] = "500 Can not connect E-Mail server: ({$ConnectAddress}).";
$result [2] = $log;
return $result;
}
$result [0] = $reply;
$result [2] = $log;
return $result;
}
?>