views:

34

answers:

2

I'm using Zend Mail library to access email and download email attachments. Is there a way to determine the attachment's filesize before downloading?

A: 

Have you taken a look at PHP's filesize(); function?

http://php.net/manual/en/function.filesize.php

It prints the file size in bytes but obviously you can convert it to whatever you want!

RageD
That's not applicable. There is no file resource to pass to the filesize() method. Remember, I want to get the filesize of the attachment BEFORE downloading it.
StackOverflowNewbie
A: 

You don't say how you are 'downloading' it. There are many ways to receive an email. The simplest three are:

  1. SMTP - No, there is no way,
  2. POP3 - I think servers typically provide size of the total email, not sure, and
  3. IMAP - I really don't recall

The answer is in the protocol you are using to retrieve (download). If you don't know that, at least you should know the PHP function you're using, so you should mention that.

Slartibartfast
I'm using Zend Mail library. Currently downloading from POP3, but would like a solution that works for other protocols.
StackOverflowNewbie
http://framework.zend.com/apidoc/1.10/Zend_Mail/Protocol/Zend_Mail_Protocol_Pop3.htmlIt looks like you'll need to find another library if you want something protocol independent (the two protocols don't share any useful (for this) common methods)
Slartibartfast
In IMAP BODYSTRUCTURE has the size information.
Pawel Lesnikowski