NotifySmtpCheck.php
[Pman.Core] / NotifySmtpCheck.php
1 <?php
2
3 require_once 'Pman.php';
4 require_once "Mail.php";
5 require_once 'Mail/smtpmx.php';
6         
7 class Pman_Core_NotifySmtpCheck extends Pman
8 {
9     static $cli_desc = "Check SMTP";
10  
11     static $cli_opts = array();
12         
13     function get()
14     {
15         $this->check();
16         
17     }
18     
19     function check()
20     {
21         $ff = HTML_FlexyFramework::get();
22         
23         if(
24                 empty($ff->Core_Notify) ||
25                 empty($ff->Core_Notify['routes'])
26         ){
27             return;
28         }
29         
30         $ifconfig = file_get_contents("https://ifconfig.co/");
31         $dom = new DomDocument('1.0', 'utf-8');
32         $dom->loadHTML($ifconfig);
33         
34         $xpath = new DOMXPath($dom);
35         
36         $element = $xpath->query("//code[@class='ip']");
37         
38         if(!$element->length){
39             return;
40         }
41         
42         print_R($element->item(0));exit;
43         
44         print_R($lists);exit;
45         
46         $error = array();
47         
48         foreach ($ff->Core_Notify['routes'] as $server => $settings){
49             if(empty($settings['domains']) || empty($settings['username']) || empty($settings['password'])){
50                 $error[] = "{$server} missing domains / username / password";
51                 continue;
52             }
53             
54             foreach ($settings['domains'] as $dom){
55                 
56                 $socket_options = array (
57                     'ssl' => array(
58                         'verify_peer'  => false,
59                         'verify_peer_name'  => false,
60                         'allow_self_signed' => true
61                     )
62                 );
63                 
64                 $smtp = new Net_SMTP($server, $settings['port'], '058177247238.ctinets.com', false, 0, $socket_options);
65                 
66                 $smtp->setDebug(true);
67                 
68                 $res = $smtp->connect(10);
69                 
70                 if (is_a($res, 'PEAR_Error')) {
71                     die("Cound not connect to {$server}");
72                 }
73                 
74                 $res = $smtp->auth($settings['username'], $settings['password']);
75             
76                 if (is_a($res, 'PEAR_Error')) {
77                     die($res);
78                 }
79                 
80                 print_R("SUCCESS? {$res} \n");
81                 exit;
82                    
83             }
84             
85             
86         }
87     }
88     
89 }