SSilence / php-imap-client

a easy solution for simple IMAP email access in php
MIT License
268 stars 138 forks source link

EXCEL attachment #239

Open nemcko16 opened 5 years ago

nemcko16 commented 5 years ago

Imap client do not show excel attachment. Can you help. Excel is not in TypeAttachments.php

cbielich commented 5 years ago

I'm having the same issue but I have noticed that it is not just with excel but all of the office files (xls,xlsx,doc,docx,....)

I have edited the TypeAttachments.php file to include those attachments but that does not seem to do the trick.

Does anyone have an idea why this is happening?

cbielich commented 5 years ago

Ok, I am getting somewhere on this, I would make changes to the code but I am not sure exactly why it works.

The issue so far that I have been able to come up with is that has to do with the sections of the email and where the attachments are placed.

In IncomingMessage.php you will see const SECTION_ATTACHMENTS = 1;

if I change it to const SECTION_ATTACHMENTS = 0; then I am able to receive all my attachments like excel and word docs where before I was not able to. What is weird is that leaving it as 1 does allow some attachments to come in but not all unless I change it to 0.

The only issue so far with changing it to 0 is that it will also produce some empty results (attachments) so I am stuck here so far. Still digging through the code but I am getting close.

hokascha commented 4 years ago

In TypeAttachments.php add the correct mime type to the $types array. For example, Powerpoint PPTX file has type "VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.PRESENTATION", some more:

Excel (.xls): VND.MS-EXCEL Excel (.xlsx): VND.OPENXMLFORMATS-OFFICEDOCUMENT.SPREADSHEETML.SHEET Adobe Illustrator (.ai): ILLUSTRATOR

Using "MIXED" might give you empty attachments. I simply check for empty names in that case.