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

mb_decode_mimeheader() fails on emails with multiple references #51

Closed
petar-djuric opened this issue Dec 4, 2020 · 2 comments
Closed
Labels
bug Something isn't working validated

Comments

@petar-djuric
Copy link

Describe the bug
I'm using laravel however this seems to be a php-imap issue so I will post it here. The connection used was gmail with the settings described in the wiki (app-password)

mb_decode_mimeheader() expects parameter 1 to be string, array given
on src/Header.php  private function decode($value)
on line 388

I have traced the issue back to 'References:' raw header

unknown

On normal emails, there is only one reference but some emails can have a hierarchy of emails in them so it picks up multiple references. This causes the public function rfc822_parse_headers($raw_headers) on line 171 to parse 'References:' as an array rather than a string.

To Reproduce
Steps to reproduce the behavior:

  1. use gmail connection (app password)
$client->connect();
       return $client->getFolders('folder name')->messages()->all()->get();
  1. emails with multiple references will fail on mb_decode_mimeheader()

Desktop / Server (please complete the following information):

  • OS: macos 10.15.7 (19H2)
  • PHP: 7.4.13

Additional context
This only happens when an email contains multiple 'References:' on a single reference the behaviour is normal with out any issues.

@lutchin
Copy link

lutchin commented Dec 10, 2020

I have the same problem.
solution to the problem:

`\vendor\webklex\php-imap\src\Header.php 145

  if (property_exists($header, 'references')) {
        !is_array($header->references)?:$header->references=$header->references[1];
        $this->attributes["references"] = $this->decode($header->references);
    }`

Webklex added a commit that referenced this issue Dec 10, 2020
@Webklex Webklex added bug Something isn't working validated labels Dec 10, 2020
@Webklex
Copy link
Owner

Webklex commented Dec 11, 2020

Hi @lutchin ,
thanks for your report 👍

Please update your php-imap dependency to v2.2.5.

Best regards,

@Webklex Webklex closed this as completed Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working validated
Projects
None yet
Development

No branches or pull requests

3 participants