icaine / php-mime-mail-parser

Automatically exported from code.google.com/p/php-mime-mail-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attachments do not return file names

GoogleCodeExporter opened this issue · comments

What steps will reproduce the problem?
1. Retrieve filenames via $attachments = $Parser->getAttachments();
2. or $Parser->getAttachmentsAsStreams();

What is the expected output? What do you see instead?
The file or stream, and the filename
Instead you just get the file, or stream, there is no way to deduce the 
filename or type.



Original issue reported on code.google.com by buca...@gmail.com on 2 Aug 2009 at 7:35

Now there are getAttachmentsFilenames() and getAttachmentsTypes() available.
They work in a similar way as getAttachments() does, returning an array of 
values.
IMHO, there are too mucho functions to do essentialy similar tasks. It would 
provably be better to have one function for returning a bi-dimentional array, 
containing the attachments (or a file descriptors to them), their's 
conetnt-types 
and filenames. I don't know which attachment's header is more relayable for 
this 
matter, "name" or "filename".

Original comment by alkne...@gmail.com on 3 Aug 2009 at 4:46

After thinking about it, I think all the headers should be available in 
attachments. Some users may want to process other headers as well as their own 
custom X-* headers. 

I've committed a new class, MimeMailParser_attachment which models attachments. 

So the new way of retrieving attachments is:

{{{
$attachments = $MimeMailParser->getAttachments();
foreach($attachments as $attachment) {

  $filename = $attachment->filename;
  $content = $attachment->content;
  $content_type = $attachment->content_type;
  $raw_headers = $attachment->headers;
 // etc.
}
}}}

For some reason I couldn't add a commit log when committing those changes.






Original comment by buca...@gmail.com on 3 Aug 2009 at 10:25

Other special case for double extension would be ".tar.bz2".

IMHO, getting the extension from the filename seems more like a generic string 
function, not too much to do with e-mail parsing. For porpouse of 
identification of 
the file type, in the context of a e-mail message, usage of mime-type makes 
much 
more sense. In any case, no harm to have this functionality. Also, if there is 
some 
kind of .bash_profile or .forward file attached to a mail, this can be a mess.

Original comment by alkne...@gmail.com on 4 Aug 2009 at 3:28

True true. I think we should remove the getExtension() function. 

Original comment by buca...@gmail.com on 4 Aug 2009 at 12:34

Fixed in r12

Original comment by buca...@gmail.com on 8 Oct 2009 at 8:41

  • Changed state: Fixed