Skip to content

Cannot assign null to property Webklex\PHPIMAP\Address::$host of type string #388

Closed
@felipehertzer

Description

@felipehertzer

Describe the bug
Hello, @Webklex
I have a problem reading messages from an inbox where the email was sent only to bbc without a proper "To".
When it happens the email header comes with the information below, being an invalid email address:

To: "Undisclosed Recipients" <>

'To' parsed with 'Webklex\PHPIMAP\Message->parseRawHeader()':

'to' => 
    array (
      0 => 
      (object) array(
         'mailbox' => 'Undisclosed Recipients',
         'host' => 'UNKNOWN',
      ),
      1 => 
      (object) array(
         'mailbox' => 'UNEXPECTED_DATA_AFTER_ADDRESS',
         'host' => '.SYNTAX-ERROR.',
      ),
    ),

These errors are showing in my log:

Uncaught ErrorException: PHP Request Shutdown: Unexpected characters at end of address: <> (errflg=3) in Unknown:0
Cannot assign null to property Webklex\PHPIMAP\Address::$host of type string

Thank you.

Code to Reproduce
The troubling code section which produces the reported bug.

$query = $folder
                ->query()
                ->setFetchOrderDesc()
                ->limit(50);
 $messages = $query->get();

Desktop / Server (please complete the following information):

  • OS: MacOS
  • PHP: 8.2
  • Version 5.0.1
  • Provider Postfix Server

Additional context

Cannot assign null to property Webklex\PHPIMAP\Address::$host of type string
Level
CRITICAL
Code
0
File
/var/task/vendor/webklex/php-imap/src/Address.php
Line
43
Trace
#0 /var/task/vendor/webklex/php-imap/src/Header.php(603): Webklex\PHPIMAP\Address->__construct()
#1 /var/task/vendor/webklex/php-imap/src/Header.php(558): Webklex\PHPIMAP\Header->parseAddresses()
#2 /var/task/vendor/webklex/php-imap/src/Header.php(182): Webklex\PHPIMAP\Header->extractAddresses()
#3 /var/task/vendor/webklex/php-imap/src/Header.php(64): Webklex\PHPIMAP\Header->parse()
#4 /var/task/vendor/webklex/php-imap/src/Message.php(512): Webklex\PHPIMAP\Header->__construct()
#5 /var/task/vendor/webklex/php-imap/src/Message.php(286): Webklex\PHPIMAP\Message->parseRawHeader()
#6 /var/task/vendor/webklex/php-imap/src/Query/Query.php(277): Webklex\PHPIMAP\Message::make()
#7 /var/task/vendor/webklex/php-imap/src/Query/Query.php(353): Webklex\PHPIMAP\Query\Query->make()
#8 /var/task/vendor/webklex/php-imap/src/Query/Query.php(315): Webklex\PHPIMAP\Query\Query->populate()
#9 /var/task/vendor/webklex/php-imap/src/Query/Query.php(378): Webklex\PHPIMAP\Query\Query->curate_messages()
#10 /var/task/app/Services/ImapService.php(141): Webklex\PHPIMAP\Query\Query->get()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions