Can I prevent IMAP from grabbing files over X mb using PHP?
I'm building a little script that will connect to an IMAP account and grab the content of the email and also the attachments. It works well for 开发者_如何学编程the most part, but when a really large file comes in, it causes the script to time out. Is there any way that I can check the file size before trying to grab it? I think that would be the simplest solution. Otherwise, I may have to upgrade to a server that has more memory.
Check out imap-fetch-overview() and imap-fetchstructure()
They look like they'll give you the size in bytes (depending on the server).
You can use imap_fetch_overview to retrieve information for one or more headers, including the size.
精彩评论