Skip to content

Conversation

stefanullrich
Copy link

@stefanullrich stefanullrich commented Sep 8, 2025

Pull Request

Description

This will fix a problem with the header encoding detection on specific mails.

Fixes #595

Problem

While listing the content of a specific folder with something like

$messages = $folder->messages()->all()->get();

We are receiving an ErrorException:

Uninitialized string offset 0

which is based on the composer autoload feature.

This error occurs, if there is a mail within the folder (mainly spam messages) containing the following From-header:

...
Message-ID: <[email protected]>
From: "\"High-Speed-Deal\" ." <[email protected]>
Date: Wed, 28 Aug 2025 12:31:41 +0000
...

If such a mail is parsed, the following string ('\\') is passed to the getEncoding function in HeaderDecoder.php and then in line 68:

if (property_exists('\\', 'parameters')) {

This will cause composer to try to autoload the "class" and then the exception is thrown.

Solution

To prevent the autoloading, a check is performed to see whether $structure is an object. If all conditions within the getEncoding() method fail, the fallback encoding is returned.

@stefanullrich
Copy link
Author

Hello @Webklex,
Is there a way to merge this, or is something unclear?

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

Successfully merging this pull request may close these issues.

Header Encoding Detection Problem
1 participant