Skip to content

Bad parsing of non-standard headers leading to getFrom() returning string #35

Closed
@itkfm

Description

@itkfm

Describe the bug
Message::getFrom() returns a string instead of an object for mails with such a header:

From: "Facebook" <notification@facebookmail.com>
To: "…" <…>
Subject: …
Date: Fri, 1 Oct 2020 01:01:01 +0200
Message-ID: <…@facebookmail.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_…"
X-Priority: 3
X-Mailer: ZuckMail [version 1.00]
Thread-Index: …==
X-Facebook: from 2401:db00:321c:e0b:face:0:170:0 ([MTI3LjAuMC4x]) 
	by www.facebook.com with HTTPS (ZuckMail);
X-Facebook-Notify: msg; from=123456789012345; t=cid.c.…:…; mailid=…
X-FACEBOOK-PRIORITY: 0
X-Auto-Response-Suppress: All

To Reproduce
Steps to reproduce the behavior:

  1. Fetch a mail like the above one
    // […]
    $folders = $c->getFolders();
    foreach ($folders as $folder) {
        $msgs = $folder->messages();
        $msgs = $msgs->setFetchBody(false);
        $mails = $msgs->all()->get();
        foreach ($mails as $mail) {
            var_dump($mail->getFrom());
  2. you'll get
    string(15) "123456789012345"

Expected behavior

[0]=>
  object(stdClass)#1234 (5) {
    ["personal"]=>
    string(35) "Facebook"
    ["mailbox"]=>
    string(5) "notification"
    ["host"]=>
    string(8) "facebookmail.com"
    ["mail"]=>
    string(14) "notification@facebookmail.com"
    ["full"]=>
    string(52) "Facebook <notification@facebookmail.com>"
  }
}

Desktop:

  • OS: GNU/Linux
  • PHP: 7.4.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions