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     function check()
10     {
11         $ff = HTML_FlexyFramework::get();
12         
13         if(
14                 empty($ff->Core_Notify) ||
15                 empty($ff->Core_Notify['routes'])
16         ){
17             return;
18         }
19         
20         $error = array();
21         
22         foreach ($ff->Core_Notify['routes'] as $server => $settings){
23             if(empty($settings['domains']) || empty($settings['username']) || empty($settings['password'])){
24                 $error[] = "{$server} missing domains / username / password";
25                 continue;
26             }
27             
28             foreach ($settings['domains'] as $dom){
29 //                $mailer = Mail::factory('smtp', array(
30 //                    'host'    => $dom ,
31 //                    'localhost' => $server,
32 //                    'timeout' => 15,
33 //                    'auth' => true,
34 //                    'username' => $settings['username'],
35 //                    'password' => $settings['password']
36 //                ));
37 //                
38 //                print_R($mailer);exit;
39                 
40                 $headers = array(
41                     'From' => $settings['username']
42                 );
43                 
44                 $params = array(
45                     'netdns' => false
46                 );
47                 
48                 $smtpmx = new Mail_smtpmx($params);
49                 
50                 $result = $smtpmx->_sanitizeHeaders($headers);
51                 if (is_a($result, 'PEAR_Error')) {
52                     $this->jerr("Error occour on '_sanitizeHeaders' \n");
53                 }
54
55                 $smtpmx->_smtp = new Net_SMTP($server, $smtpmx->port, $smtpmx->mailname);
56                     
57 //                print_R($smtpmx->_smtp);exit;
58                 
59                 $res = $smtpmx->_smtp->connect($smtpmx->timeout);
60                 
61                 if (is_a($res, 'PEAR_Error')) {
62                     print_R('error?????');exit;
63                 }
64             
65                 $smtpmx->_smtp->disconnect();
66
67                 print_R($res);exit;
68                     
69 //                $mx = $smtpmx->_getMx($dom);
70 //                
71 //                foreach ($mx as $mserver => $mpriority) {
72 //                    
73 //                    $smtpmx->_smtp = new Net_SMTP($mserver, $smtpmx->port, $smtpmx->mailname);
74 //                    
75 ////                    print_R($smtpmx);exit;
76 //                    $res = $smtpmx->_smtp->connect($smtpmx->timeout);
77 //
78 //                    $smtpmx->_smtp->disconnect();
79 //                    
80 //                    print_R($res);exit;
81 //                }
82                 
83             }
84             
85             
86         }
87     }
88     
89 }