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