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