3333class Client {
3434 use HasEvents;
3535
36-
3736 /**
3837 * @var boolean|Protocol
3938 */
@@ -103,14 +102,6 @@ class Client {
103102 */
104103 protected $ active_folder = false ;
105104
106- /**
107- * All valid and available account config parameters
108- *
109- * @var array $validConfigKeys
110- */
111- protected $ valid_config_keys = ['host ' , 'port ' , 'encryption ' , 'validate_cert ' , 'username ' , 'password ' , 'protocol ' ,
112- 'authentication ' ];
113-
114105 /**
115106 * @var string $default_message_mask
116107 */
@@ -121,6 +112,20 @@ class Client {
121112 */
122113 protected $ default_attachment_mask = AttachmentMask::class;
123114
115+ /**
116+ * @var array $default_account_config
117+ */
118+ protected $ default_account_config = [
119+ 'host ' => 'localhost ' ,
120+ 'port ' => 993 ,
121+ 'protocol ' => 'imap ' ,
122+ 'encryption ' => 'ssl ' ,
123+ 'validate_cert ' => true ,
124+ 'username ' => '' ,
125+ 'password ' => '' ,
126+ 'authentication ' => null ,
127+ ];
128+
124129 /**
125130 * Client constructor.
126131 * @param array $config
@@ -151,13 +156,28 @@ public function setConfig(array $config) {
151156 $ default_account = ClientManager::get ('default ' );
152157 $ default_config = ClientManager::get ("accounts. $ default_account " );
153158
154- foreach ($ this ->valid_config_keys as $ key ) {
155- $ this ->$ key = isset ( $ config [ $ key]) ? $ config[ $ key ] : $ default_config[ $ key ] ;
159+ foreach ($ this ->default_account_config as $ key => $ value ) {
160+ $ this ->setAccountConfig ( $ key, $ config, $ default_config) ;
156161 }
157162
158163 return $ this ;
159164 }
160165
166+ /**
167+ * @param string $key
168+ * @param array $config
169+ * @param array $default_config
170+ */
171+ private function setAccountConfig ($ key , $ config , $ default_config ){
172+ $ value = $ this ->default_account_config [$ key ];
173+ if (isset ($ config [$ key ])) {
174+ $ value = $ config [$ key ];
175+ }elseif (isset ($ default_config [$ key ])) {
176+ $ value = $ default_config [$ key ];
177+ }
178+ $ this ->$ key = $ value ;
179+ }
180+
161181 /**
162182 * Look for a possible events in any available config
163183 * @param $config
0 commit comments