@@ -239,6 +239,7 @@ protected function populate(Collection $uids): MessageCollection
239239 $ response ['flags ' ] ?? [],
240240 $ response ['headers ' ] ?? '' ,
241241 $ response ['contents ' ] ?? '' ,
242+ $ response ['size ' ] ?? null ,
242243 )
243244 );
244245 }
@@ -264,6 +265,10 @@ protected function fetch(Collection $messages): array
264265 $ fetch [] = 'FLAGS ' ;
265266 }
266267
268+ if ($ this ->fetchSize ) {
269+ $ fetch [] = 'RFC822.SIZE ' ;
270+ }
271+
267272 if ($ this ->fetchBody ) {
268273 $ fetch [] = $ this ->fetchAsUnread
269274 ? 'BODY.PEEK[TEXT] '
@@ -279,6 +284,7 @@ protected function fetch(Collection $messages): array
279284 if (empty ($ fetch )) {
280285 return $ uids ->mapWithKeys (fn (string |int $ uid ) => [
281286 $ uid => [
287+ 'size ' => null ,
282288 'flags ' => [],
283289 'headers ' => '' ,
284290 'contents ' => '' ,
@@ -299,8 +305,11 @@ protected function fetch(Collection $messages): array
299305
300306 $ uid = $ data ->lookup ('UID ' )->value ;
301307
308+ $ size = $ data ->lookup ('RFC822.SIZE ' )?->value;
309+
302310 return [
303311 $ uid => [
312+ 'size ' => $ size !== null ? (int ) $ size : null ,
304313 'flags ' => $ data ->lookup ('FLAGS ' )?->values() ?? [],
305314 'headers ' => $ data ->lookup ('[HEADER] ' )->value ?? '' ,
306315 'contents ' => $ data ->lookup ('[TEXT] ' )->value ?? '' ,
@@ -356,9 +365,9 @@ protected function id(int $id, ImapFetchIdentifier $identifier = ImapFetchIdenti
356365 /**
357366 * Make a new message from given raw components.
358367 */
359- protected function newMessage (int $ uid , array $ flags , string $ headers , string $ contents ): Message
368+ protected function newMessage (int $ uid , array $ flags , string $ headers , string $ contents, ? int $ size = null ): Message
360369 {
361- return new Message ($ this ->folder , $ uid , $ flags , $ headers , $ contents );
370+ return new Message ($ this ->folder , $ uid , $ flags , $ headers , $ contents, $ size );
362371 }
363372
364373 /**
0 commit comments