NotifySmtpCheck.php
[Pman.Core] / NotifySmtpCheck.php
index a6c3130..1e73473 100644 (file)
@@ -27,6 +27,24 @@ class Pman_Core_NotifySmtpCheck extends Pman
             return;
         }
         
+        $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`;
+        
         $error = array();
         
         foreach ($ff->Core_Notify['routes'] as $server => $settings){
@@ -36,23 +54,6 @@ class Pman_Core_NotifySmtpCheck extends Pman
             }
             
             foreach ($settings['domains'] as $dom){
-//                $mailer = Mail::factory('smtp', array(
-//                    'host'    => $dom ,
-//                    'localhost' => $server,
-//                    'timeout' => 15,
-//                    'auth' => true,
-//                    'username' => $settings['username'],
-//                    'password' => $settings['password']
-//                ));
-//                
-//                print_R($mailer);exit;
-                
-//                $params = array(
-//                    'netdns' => false
-//                );
-                
-//                $smtpmx = new Mail_smtpmx($params);
-//                $smtpmx->debug = true;
                 
                 $socket_options = array (
                     'ssl' => array(
@@ -62,12 +63,9 @@ class Pman_Core_NotifySmtpCheck extends Pman
                     )
                 );
                 
-                $smtp = new Net_SMTP($server, 25, '058177247238.ctinets.com', false, 0, $socket_options);
+                $smtp = new Net_SMTP($server, $settings['port'], '058177247238.ctinets.com', false, 0, $socket_options);
                 
                 $smtp->setDebug(true);
-//                print_R($smtp);
-                
-//                print_R($smtpmx->_smtp);exit;
                 
                 $res = $smtp->connect(10);
                 
@@ -77,24 +75,13 @@ class Pman_Core_NotifySmtpCheck extends Pman
                 
                 $res = $smtp->auth($settings['username'], $settings['password']);
             
-//                $smtpmx->_smtp->disconnect();
-                print_r("resutlt : {$res} \n");
-                exit;
-                    
-//                $mx = $smtpmx->_getMx($dom);
-//                
-//                foreach ($mx as $mserver => $mpriority) {
-//                    
-//                    $smtpmx->_smtp = new Net_SMTP($mserver, $smtpmx->port, $smtpmx->mailname);
-//                    
-////                    print_R($smtpmx);exit;
-//                    $res = $smtpmx->_smtp->connect($smtpmx->timeout);
-//
-//                    $smtpmx->_smtp->disconnect();
-//                    
-//                    print_R($res);exit;
-//                }
+                if (is_a($res, 'PEAR_Error')) {
+                    die($res);
+                }
                 
+                print_R("SUCCESS? {$res} \n");
+                exit;
+                   
             }