-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotifySmtpCheck.php
108 lines (78 loc) · 2.65 KB
/
NotifySmtpCheck.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
require_once 'Pman.php';
class Pman_Core_NotifySmtpCheck extends Pman
{
function __construct()
{
require_once "Mail.php";
require_once 'Mail/smtpmx.php';
}
function get($v, $opts=array())
{
$this->check();
exit;
}
function check()
{
$ff = HTML_FlexyFramework::get();
if(
empty($ff->Core_Notify) ||
empty($ff->Core_Notify['routes'])
){
return;
}
$helo = $this->getHelo();
echo "HELO : {$helo} \n";
$error = array();
foreach ($ff->Core_Notify['routes'] as $server => $settings){
if(empty($settings['domains']) || empty($settings['username']) || empty($settings['password'])){
$error[] = "{$server} - Missing domains / username / password";
continue;
}
$socket_options = array (
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
);
if (empty($settings['port'])) {
$settings['port'] = 25;
}
$smtp = new Net_SMTP($server, $settings['port'], $helo, false, 0, $socket_options);
// $smtp->setDebug(true);
echo "Connecting : {$server}:{$settings['port']} \n";
$res = $smtp->connect(10);
if (is_a($res, 'PEAR_Error')) {
$error[] = "{$server} - Cound not connect";
continue;
}
echo "Login As : {$settings['username']}:{$settings['password']} \n";
$res = $smtp->auth($settings['username'], $settings['password']);
if (is_a($res, 'PEAR_Error')) {
$error[] = "{$server} - Cound not login";
continue;
}
}
if(!empty($error)){
print_r($error);
exit;
}
return;
}
function getHelo()
{
$ifconfig = file_get_contents("https://ifconfig.co/");
$dom = new DomDocument('1.0', 'utf-8');
@$dom->loadHTML($ifconfig);
$xpath = new DOMXPath($dom);
$element = $xpath->query("//code[@class='ip']");
if(!$element->length){
return;
}
$ip = $element->item(0)->nodeValue;
$cmd = "host {$ip}";
$e = `$cmd`;
$helo = substr(array_pop(explode(' ', $e)), 0, -2);
return $helo;
}
}