@@ -117,7 +117,13 @@ public function folderStatus(string $folder = 'INBOX', array $arguments = ['MESS
117117 */
118118 public function createFolder (string $ folder ): ResponseCollection
119119 {
120- $ this ->send ('CREATE ' , [$ this ->escapeString ($ folder )]);
120+ $ this ->send ('CREATE ' , [$ this ->escapeString ($ folder )], $ tag );
121+
122+ $ this ->assertTaggedResponse ($ tag , fn () => new RuntimeException ('Failed to create folder ' ));
123+
124+ return $ this ->result ->responses ()->untagged ()->filter (
125+ fn (UntaggedResponse $ response ) => $ response ->type ()->is ('LIST ' )
126+ );
121127 }
122128
123129 /**
@@ -193,52 +199,66 @@ public function appendMessage(string $folder, string $message, ?array $flags = n
193199
194200 $ tokens [] = $ this ->escapeString ($ message );
195201
196- return $ this ->send ('APPEND ' , $ tokens );
202+ $ this ->send ('APPEND ' , $ tokens , tag: $ tag );
203+
204+ $ this ->assertTaggedResponse ($ tag , fn () => new RuntimeException ('Failed to append message ' ));
205+
206+ return $ this ->result ->responses ()->untagged ()->filter (
207+ fn (UntaggedResponse $ response ) => $ response ->type ()->is ('LIST ' )
208+ );
197209 }
198210
199211 /**
200212 * {@inheritDoc}
201213 */
202- public function copyMessage (string $ folder , $ from , ?int $ to = null ): ResponseCollection
214+ public function copyMessage (string $ folder , $ from , ?int $ to = null ): void
203215 {
204- return $ this ->send ('UID COPY ' , [
216+ $ this ->send ('UID COPY ' , [
205217 $ this ->buildSet ($ from , $ to ),
206218 $ this ->escapeString ($ folder ),
207- ]);
219+ ], $ tag );
220+
221+ $ this ->assertTaggedResponse ($ tag , fn () => new RuntimeException ('Failed to copy message ' ));
208222 }
209223
210224 /**
211225 * {@inheritDoc}
212226 */
213- public function copyManyMessages (array $ messages , string $ folder ): ResponseCollection
227+ public function copyManyMessages (array $ messages , string $ folder ): void
214228 {
215229 $ set = implode (', ' , $ messages );
216230
217231 $ tokens = [$ set , $ this ->escapeString ($ folder )];
218232
219- $ this ->send ('UID COPY ' , $ tokens );
233+ $ this ->send ('UID COPY ' , $ tokens , $ tag );
234+
235+ $ this ->assertTaggedResponse ($ tag , fn () => new RuntimeException ('Failed to copy messages ' ));
220236 }
221237
222238 /**
223239 * {@inheritDoc}
224240 */
225- public function moveMessage (string $ folder , $ from , ?int $ to = null ): ResponseCollection
241+ public function moveMessage (string $ folder , $ from , ?int $ to = null ): void
226242 {
227243 $ set = $ this ->buildSet ($ from , $ to );
228244
229- return $ this ->send ('UID MOVE ' , [$ set , $ this ->escapeString ($ folder )]);
245+ $ this ->send ('UID MOVE ' , [$ set , $ this ->escapeString ($ folder )], $ tag );
246+
247+ $ this ->assertTaggedResponse ($ tag , fn () => new RuntimeException ('Failed to move message ' ));
230248 }
231249
232250 /**
233251 * {@inheritDoc}
234252 */
235- public function moveManyMessages (array $ messages , string $ folder ): ResponseCollection
253+ public function moveManyMessages (array $ messages , string $ folder ): void
236254 {
237255 $ set = implode (', ' , $ messages );
238256
239257 $ tokens = [$ set , $ this ->escapeString ($ folder )];
240258
241- return $ this ->send ('UID MOVE ' , $ tokens );
259+ $ this ->send ('UID MOVE ' , $ tokens , $ tag );
260+
261+ $ this ->assertTaggedResponse ($ tag , fn () => new RuntimeException ('Failed to move messages ' ));
242262 }
243263
244264 /**
0 commit comments