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

Zend\Mail\Storage\Mbox can't fetch messages due to header issues #37

Open
michalbundyra opened this issue Jan 15, 2020 · 3 comments
Open

Comments

@michalbundyra
Copy link
Member

PHP 7.2.2, Zend Mail at it's latest version as of today.

I'm opening an old mailbox file generated by Mozilla Thunderbird (please note that I get the same issue with other Thunderbird mailbox files). It has 2,521 messages and every single one of them causes this Zend\Mail\Exception\RuntimeException.

This issue happens:

  1. When trying to iterate through the mailbox file with a foreach (as shown in the docs);
  2. When trying to fetch a specific message after iterating via a count() + regular for loop .

And it's located at zendframework/zend-mail/src/Headers.php on line 109.

The exact headers causing the issue are X-Mozilla-Status and X-Account-Key. See the sample below (I've removed [potentially] sensitive data such as e-mail addresses, etc... for obvious reasons).

Line "X-Mozilla-Status: 0019
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:                                                                                 
Received: (qmail 20021 invoked from network); 24 Apr 2008 14:23:38 -0300
Received: from [redacted].google.com (216.239.58.185) by [redacted]
        with SMTP; 24 Apr 2008 14:23:38 -0300
Received-SPF: softfail ([redacted]: transitioning SPF record at
        [redacted] does not designate [redacted] as permitted sender)
Received: by [redacted].google.com with SMTP id [redacted] for
        <[redacted]>; Thu, 24 Apr 2008 11:36:07 -0700 (PDT)
Received: by 10.150.49.1 with SMTP id [redacted]; Thu,
        24 Apr 2008 11:35:17 -0700 (PDT)
Received: by [redacted] with HTTP; Thu, 24 Apr 2008 11:35:17 -0700 (PDT)
Message-ID: <[redacted]@mail.gmail.com>
Date: Thu, 24 Apr 2008 15:35:17 -0300
From: "[redacted]" <[redacted]>
To: [redacted]
Subject: =?ISO-8859-1?[redacted]?=
In-Reply-To: <[redacted]>
MIME-Version: 1.0
Content-Type: multipart/related;  boundary="----=_Part_22_2026612.1209062117791"
References: <[redacted]>
X-Evolution-Source: [redacted]
X-Evolution: [redacted]
" does not match header format!


Originally posted by @galvao at zendframework/zend-mail#193

@michalbundyra
Copy link
Member Author

I believe a clarification is in order: I simply cannot fetch these messages. It doesn't matter if I catch this Exception or not, which is the reason for this issue.


Originally posted by @galvao at zendframework/zend-mail#193 (comment)

@michalbundyra
Copy link
Member Author

Update: Using the second method (count + for loop) it's possible to catch the Exception, but still, every single message causes this Exception, making the task of reading these messages absolutely impossible.
Since Custom Headers seem to be a common thing, I'd remove this exception entirely or at least modify Zend\Mail so the presence of such a header doesn't block the entire operation of fetching a message.


Originally posted by @galvao at zendframework/zend-mail#193 (comment)

@puecher
Copy link

puecher commented Nov 20, 2020

What about using

const EOL = PHP_EOL;

const FOLDING = PHP_EOL . " ";

in https://github.com/laminas/laminas-mail/blob/2.13.x/src/Headers.php#L30

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

No branches or pull requests

2 participants