@@ -275,4 +275,50 @@ public function seeAnAttachment($bool)
275
275
276
276
$ this ->assertEquals ($ bool , count ($ attachments ) > 0 );
277
277
}
278
+
279
+ /**
280
+ * Get the most recent messages of the default inbox.
281
+ *
282
+ * @param int $number
283
+ *
284
+ * @return array
285
+ */
286
+ public function fetchLastMessages ($ number = 1 )
287
+ {
288
+ $ messages = $ this ->client ->get ("inboxes/ {$ this ->config ['inbox_id ' ]}/messages " )->getBody ();
289
+ if ($ messages instanceof Stream) {
290
+ $ messages = $ messages ->getContents ();
291
+ }
292
+
293
+ $ messages = json_decode ($ messages , true );
294
+
295
+ $ firstIndex = count ($ messages ) - $ number ;
296
+
297
+ $ messages = array_slice ($ messages , $ firstIndex , $ number );
298
+
299
+ $ this ->assertCount ($ number , $ messages );
300
+
301
+ return $ messages ;
302
+ }
303
+
304
+ /**
305
+ * Get the bcc property of a message
306
+ *
307
+ * @param int $messageId
308
+ *
309
+ * @return string
310
+ */
311
+ public function getBccEmailOfMessage ($ messageId )
312
+ {
313
+ $ message = $ this ->client ->get ("inboxes/ {$ this ->config ['inbox_id ' ]}/messages/ $ messageId/body.eml " )->getBody ();
314
+ if ($ message instanceof Stream) {
315
+ $ message = $ message ->getContents ();
316
+ }
317
+ $ matches = [];
318
+ preg_match ('/Bcc:\s[\w.-]+@[\w.-]+\.[a-z]{2,6}/ ' , $ message , $ matches );
319
+
320
+ $ bcc = substr (array_shift ($ matches ),5 );
321
+
322
+ return $ bcc ;
323
+ }
278
324
}
0 commit comments