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 check()
14     {
15         $ff = HTML_FlexyFramework::get();
16         
17         if(
18                 empty($ff->Core_Notify) ||
19                 empty($ff->Core_Notify['routes'])
20         ){
21             return;
22         }
23         
24         $error = array();
25         
26         foreach ($ff->Core_Notify['routes'] as $server => $settings){
27             if(empty($settings['domains']) || empty($settings['username']) || empty($settings['password'])){
28                 $error[] = "{$server} missing domains / username / password";
29                 continue;
30             }
31             
32             foreach ($settings['domains'] as $dom){
33 //                $mailer = Mail::factory('smtp', array(
34 //                    'host'    => $dom ,
35 //                    'localhost' => $server,
36 //                    'timeout' => 15,
37 //                    'auth' => true,
38 //                    'username' => $settings['username'],
39 //                    'password' => $settings['password']
40 //                ));
41 //                
42 //                print_R($mailer);exit;
43                 
44                 $params = array(
45                     'netdns' => false
46                 );
47                 
48                 $smtpmx = new Mail_smtpmx($params);
49                 $smtpmx->debug = true;
50                 
51                 $smtpmx->_smtp = new Net_SMTP($server, $smtpmx->port, $smtpmx->mailname);
52                 
53                 $smtpmx->_smtp->setDebug(true);
54                 
55 //                print_R($smtpmx->_smtp);exit;
56                 
57                 $res = $smtpmx->_smtp->connect($smtpmx->timeout);
58                 
59                 if (is_a($res, 'PEAR_Error')) {
60                     print_R('error?????');exit;
61                 }
62             
63 //                $smtpmx->_smtp->disconnect();
64
65                 print_R($res);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 }