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         $xpath = new DOMXPath($dom);
34         $lists = $xpath->query("code[@class='ip]");
35         
36         
37         print_R($lists);exit;
38         
39         $error = array();
40         
41         foreach ($ff->Core_Notify['routes'] as $server => $settings){
42             if(empty($settings['domains']) || empty($settings['username']) || empty($settings['password'])){
43                 $error[] = "{$server} missing domains / username / password";
44                 continue;
45             }
46             
47             foreach ($settings['domains'] as $dom){
48                 
49                 $socket_options = array (
50                     'ssl' => array(
51                         'verify_peer'  => false,
52                         'verify_peer_name'  => false,
53                         'allow_self_signed' => true
54                     )
55                 );
56                 
57                 $smtp = new Net_SMTP($server, $settings['port'], '058177247238.ctinets.com', false, 0, $socket_options);
58                 
59                 $smtp->setDebug(true);
60                 
61                 $res = $smtp->connect(10);
62                 
63                 if (is_a($res, 'PEAR_Error')) {
64                     die("Cound not connect to {$server}");
65                 }
66                 
67                 $res = $smtp->auth($settings['username'], $settings['password']);
68             
69                 if (is_a($res, 'PEAR_Error')) {
70                     die($res);
71                 }
72                 
73                 print_R("SUCCESS? {$res} \n");
74                 exit;
75                    
76             }
77             
78             
79         }
80     }
81     
82 }