Open slotone opened 4 years ago
Hello,
Could you attach to your issue a raw email with a zero sized attachment?
Hi Vincent,
After some testing we found the issue ocurrs with some attachments that are not being properly processed and therefore their result size is zero.
So far this issue seems to be only related to EML attachment files, so please find the sample.txt file we provide for you to test. The attached file is a raw mime email having an EML attachment inside (which is the one that is not being properly processed).
One error I've seen during this tests is: stream_get_contents(): supplied resource is not a valid stream resource [file] => /php-mime-mail-parser/src/Attachment.php [line] => 210
sample.txt Email addresses, domains and names were modified to preserve privacy.
This issue (EML attachment files not being parsed) happens frequently, but we didn't find a pattern so far. Worth to mention that EML Viewer in Gmail is able to properly display the EML attachment.
Please let us know if this helps to find a fix for it.
Thanks in advance!
Sorry I didn't have time to look at it. I plan to do it before the end of the year ;)
Thanks for your issue.
I also experienced this problem and found a cause.
Attachment::create()
- when attachment does not have filename, it calls Parser::fromStream()
with stream as parameter https://github.com/php-mime-mail-parser/php-mime-mail-parser/blob/e6b62963999fc9b5676a5bad0bc8fcfd387ae564/src/Attachment.php#L75Parser::fromStream()
does some his stuff, but unfortunately it closes the input stream that came in parameter https://github.com/php-mime-mail-parser/php-mime-mail-parser/blob/e6b62963999fc9b5676a5bad0bc8fcfd387ae564/src/Parser.php#L132Attachment->getContent()
, it tries to use the existing stream, which has been closed by Parser::fromStream()
https://github.com/php-mime-mail-parser/php-mime-mail-parser/blob/e6b62963999fc9b5676a5bad0bc8fcfd387ae564/src/Attachment.php#L210stream_get_contents(): supplied resource is not a valid stream resource
error message appearsI will create a PR to fix it.
When receiving an email with a zero sized attachment, the method getContent() throws the following message: Warning: fseek(): supplied resource is not a valid stream resource
What's the proper way to detect zero sized attachments and avoid getContent() warning ?
Thanks in advance!