@@ -32,21 +32,27 @@ class Connection
32
32
*/
33
33
public function __construct ($ mailbox , $ user , $ password , $ flags = 0 , $ retries = 0 , $ options = [])
34
34
{
35
- $ this ->mailbox = $ mailbox ;
36
35
$ this ->user = $ user ;
37
36
$ this ->password = $ password ;
38
37
$ this ->flags = $ flags ;
39
38
$ this ->retries = $ retries ;
40
39
$ this ->options = $ options ;
41
40
41
+ $ this ->openMailbox ($ mailbox );
42
+
43
+ $ this ->client = new ImapClient ();
44
+ }
45
+
46
+ public function openMailbox ($ mailbox )
47
+ {
48
+ $ this ->mailbox = $ mailbox ;
49
+
42
50
$ mailboxParts = Functions::parseMailboxString ($ mailbox );
43
51
44
52
$ this ->host = Functions::getHostFromMailbox ($ mailboxParts );
45
53
$ this ->port = $ mailboxParts ['port ' ];
46
54
$ this ->sslMode = Functions::getSslModeFromMailbox ($ mailboxParts );
47
55
$ this ->currentMailbox = $ mailboxParts ['mailbox ' ];
48
-
49
- $ this ->client = new ImapClient ();
50
56
}
51
57
52
58
/**
@@ -70,13 +76,15 @@ public static function open($mailbox, $user, $password, $flags = 0, $retries = 0
70
76
71
77
public static function reopen ($ imap , $ mailbox , $ flags = 0 , $ retries = 0 )
72
78
{
73
- if (is_a ($ imap , Connection::class)) {
74
- $ client = $ imap ->getClient ();
75
-
76
- return true ;
79
+ if (!is_a ($ imap , Connection::class)) {
80
+ return Errors::invalidImapConnection (debug_backtrace (), 1 , null );
77
81
}
78
82
79
- return imap_reopen ($ imap , $ mailbox , $ flags , $ retries );
83
+ $ imap ->openMailbox ($ mailbox );
84
+
85
+ $ success = $ imap ->connect ();
86
+
87
+ return boolval ($ success );
80
88
}
81
89
82
90
public static function ping ($ imap )
@@ -157,7 +165,7 @@ public function getHost()
157
165
/**
158
166
*
159
167
*/
160
- public function openMailbox ()
168
+ public function selectMailbox ()
161
169
{
162
170
$ this ->client ->select ($ this ->currentMailbox );
163
171
}
0 commit comments