rcube_email_server_address.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
 * 邮件服务商,通过邮件后缀来自动确定要请求的服务商
 * @author:dc
 * @time 2022/7/22 14:10
 * Class rcube_email_server_address
 */
class rcube_email_server_address{
//    /**
//     * @var int
//     */
//    public $id = 0;
//
//    /**
//     * 邮箱后缀
//     * qq.com
//     * @var string
//     */
//    public $mail_suffix;
//
//    /**
//     * ssl://imap.qq.com
//     * @var string
//     */
//    public $imap;
//
//    /**
//     * smtp.qq.com
//     * @var string
//     */
//    public $smtp;
//
//    /**
//     * 服务商名称
//     * @var string
//     */
//    public $name;
//
//
//    private $rc;
//
//    private $db;
//
//    public static $rows;
//
    /**
     * 表
     * @var string
     */
//    public $table = 'email_server_address';
    /**
     * Object constructor
     *
     * @param int   $db
     */
//    function __construct($db = null)
//    {
//
//        if(!$db){
//            $db =   rcube::get_instance()->get_dbh();
//        }
//        // 查询数据
//        $result   =   $db->query("select * from ". $db->table_name($this->table,true) );
//
//        // 获取列表
//        $rows   =   $result->fetchAll(PDO::FETCH_ASSOC);
//
//        foreach ($rows as $row){
//            static::$rows[$row['mail_suffix']] = [
//                'name'  =>  $row['service_provider'],
//                'smtp'  =>  $row['smtp'],
//                'imap'  =>  $row['imap'],
//            ];
//        }
//
//        $rows = null;
//
//    }
    public static function all($db = null)
    {
        if(!$db){
            $db =   rcube::get_instance()->get_dbh();
        }
        // 查询数据
        $result   =   $db->query("select * from ". $db->table_name('email_server_address',true) );
        // 获取列表
        $rows   =   [];
        foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $row){
            $rows[$row['mail_suffix']] = [
                'name'  =>  $row['service_provider'],
                'smtp'  =>  $row['smtp'],
                'imap'  =>  $row['imap'],
            ];
        }
        return $rows;
    }
}