Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to load Message Headers #358

Closed
addiks opened this issue Jul 4, 2018 · 6 comments
Closed

Fails to load Message Headers #358

addiks opened this issue Jul 4, 2018 · 6 comments
Labels

Comments

@addiks
Copy link

addiks commented Jul 4, 2018

When I try to download E-Mail's from an IMAP account, i get the following error message:
Type error: Argument 1 passed to Ddeboer\Imap\Message\Headers::__construct() must be an instance of stdClass, boolean given

This error happens on the first message it tries to download, which hints to it being a systematic issue rather then a broken message.

After a bit of debugging i found out that the issue is that "imap_headerinfo" returns false in Message.php at line 154.

bildschirmfoto vom 2018-07-04 17-45-47

I do not know yet why this call to imap_headerinfo fails, but at least a bit of error-handling should be added at this point to catch this error and display a nicer message.

Maybe i will write a PR for this, but first i will try to figure out why this call fails.

@addiks
Copy link
Author

addiks commented Jul 4, 2018

Looks like the call to imap_headerinfo fails because it was trying to fetch the header-info's for a "message" that was not really a message, but a contact in a public folder.

I had set my program to just iterate over all "mailboxes" to collect all mail's. The first "mailbox" it encountered was a public folder full of contacts.

When i just download the messages from the INBOX folder, everything works as expected.

Maybe there should be some better error-handling for this case. Is there a way to check beforehand if a message is actually a contact and not a message? Or if a folder does not contain messages but contacts?

@Slamdunk Slamdunk added the bug label Jul 5, 2018
@Slamdunk
Copy link
Collaborator

Slamdunk commented Jul 5, 2018

Hi, thank you for this report.

Maybe there should be some better error-handling for this case.

For sure there should be, we just didn't even imaged this case

Is there a way to check beforehand if a message is actually a contact and not a message? Or if a folder does not contain messages but contacts?

No, as we didn't know there could be contacts retrieved as messages.

We need some details to reproduce the issue and (we hope to) create a test on our Dovecot test suite, can you give us:

  • the IMAP provider (GMail?)
  • the folder structure
  • the return value of $message->getRawMessage(); you may strip sensitive data but please retain the format of that data, so instead of deleting your friend name, replace it with John Doe etc.

@addiks
Copy link
Author

addiks commented Jul 5, 2018

We host our e-mails on our own kopano instance.
The folder with the contacts is "Public folders/GAB".
The headers of the first message are:

Subject: John Doe
From: invalid@invalid
To: undisclosed-recipients:;
Date: Tue, 27 Feb 2018 09:33:15 +0000
Mime-Version: 1.0
Content-Type: application/ms-tnef; name=winmail.dat
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=winmail.dat

Also there was an base64-attachment which i did not decode because i don't have the time at the moment.

@Slamdunk
Copy link
Collaborator

Slamdunk commented Jul 6, 2018

Hi, I wasn't able to reproduce the bug because Dovecot returns all the headers you mention, even when the "email" is completely empty.

May you checkout my branch https://github.com/Slamdunk/imap/tree/false_imap_headerinfo and test that the error is now manageable?

@addiks
Copy link
Author

addiks commented Jul 9, 2018

This works for me.

Now that an appropriate exception is thrown for this case, i can catch it, ignore that "message" with it's invalid headers and carry on. Thanks!

@Slamdunk
Copy link
Collaborator

Fix released in 1.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants