3 require_once 'Pman.php';
4 require_once "Mail.php";
5 require_once 'Mail/smtpmx.php';
7 class Pman_Core_NotifySmtpCheck extends Pman
9 static $cli_desc = "Check SMTP";
11 static $cli_opts = array();
21 $ff = HTML_FlexyFramework::get();
24 empty($ff->Core_Notify) ||
25 empty($ff->Core_Notify['routes'])
30 $helo = $this->getHelo();
34 foreach ($ff->Core_Notify['routes'] as $server => $settings){
35 if(empty($settings['domains']) || empty($settings['username']) || empty($settings['password'])){
36 $error[] = "{$server} - Missing domains / username / password";
40 foreach ($settings['domains'] as $dom){
42 $socket_options = array (
44 'verify_peer' => false,
45 'verify_peer_name' => false,
46 'allow_self_signed' => true
50 $smtp = new Net_SMTP($server, $settings['port'], $helo, false, 0, $socket_options);
52 $smtp->setDebug(true);
54 $res = $smtp->connect(10);
56 if (is_a($res, 'PEAR_Error')) {
57 $error[] = "{$server} - Cound not connect";
61 $res = $smtp->auth($settings['username'], $settings['password']);
63 if (is_a($res, 'PEAR_Error')) {
64 $error[] = "{$server} - Cound not login";
75 $ifconfig = file_get_contents("https://ifconfig.co/");
76 $dom = new DomDocument('1.0', 'utf-8');
77 $dom->loadHTML($ifconfig);
79 $xpath = new DOMXPath($dom);
81 $element = $xpath->query("//code[@class='ip']");
83 if(!$element->length){
87 $ip = $element->item(0)->nodeValue;
93 $helo = substr(array_pop(explode(' ', $e)), 0, -2);