feat: add fetch message size limit

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-09-26 08:43:32 -04:00
parent 681a66862e
commit 025812fe4e
4 changed files with 145 additions and 9 deletions
+3 -1
View File
@@ -61,6 +61,7 @@ class RemoteMailService
private const COLLECTION_FILTER_OPTIONS = ['name', 'role', 'subscription'];
private const DEFAULT_MAILBOX_STATUS_ITEMS = ['MESSAGES', 'UNSEEN', 'RECENT', 'UIDNEXT', 'UIDVALIDITY'];
private const LIST_BODY_TEXT_LIMIT = 1048576; // 1 MB
private ?ImapClient $imapClient = null;
private ?SmtpClient $smtpClient = null;
@@ -304,7 +305,8 @@ class RemoteMailService
*/
public function entityList(string $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null): Generator
{
$options = FetchOptions::message()->withBodyText();
// text parts normally precede attachments, so capping TEXT avoids transferring attachment bytes
$options = FetchOptions::message()->withBodyText(self::LIST_BODY_TEXT_LIMIT);
// fast path: fetch all messages without filtering, sorting or pagination
if ($filter === null && $sort === null && $range === null) {