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

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

Closed
felipehertzer opened this issue Mar 15, 2023 · 2 comments
Labels
bug Something isn't working validated

Comments

@felipehertzer
Copy link

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()

@Webklex Webklex added bug Something isn't working validating validated and removed validating labels Mar 15, 2023
@Webklex
Copy link
Owner

Webklex commented Mar 16, 2023

Hi @felipehertzer ,
thanks for the excellent report. Please update to v5.1 and give it another try.

The "PHP Notice: PHP Request Shutdown: Unexpected characters at end of address: <> (errflg=3) in Unknown on line 0" however, will persist and is caused by this line:
https://github.com/Webklex/php-imap/blob/5.1.0/src/Header.php#L233

If you have an idea on how to make it stop, please feel welcome to push a pull request :)

Best regards,

@felipehertzer
Copy link
Author

Hi @Webklex, thank you for the fast reply, It is working now.

It seems that is only possible handle that errors with IMAP functions using the PHP functions:

imap_errors();
imap_alerts();

I will do some tests, if I can find other solution I will send a pull request.

Thank you.

@Webklex Webklex closed this as completed Jun 23, 2023
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

2 participants