ddeboer / imap

Object-oriented, fully tested PHP IMAP library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Security] Limit attachment size

ziaratban opened this issue · comments

Hi
My users can set up their email server and view the inbox and download attachments.
So to avoid too much space being occupied by a user, I have to limit the size of the attachment in stream mode.

file_put_contents(
    '/my/local/dir/' . $attachment->getFilename(),
    $attachment->getDecodedContent(maxSize:1024 , throwException:true)
);

The above sample code shows that if the attachment file download is more than 1024 B, it will throw an error.