|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33349 imap_fetchstructure() hangs on some mails
Submitted: 2005-06-15 11:36 UTC Modified: 2005-09-07 04:24 UTC
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (50.0%)
From: benjamin dot malynovytch at libertic dot fr Assigned:
Status: Not a bug Package: IMAP related
PHP Version: 5CVS-2005-06-20 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: benjamin dot malynovytch at libertic dot fr
New email:
PHP Version: OS:


 [2005-06-15 11:36 UTC] benjamin dot malynovytch at libertic dot fr
Calling imap_fetchstructure() on certain multi-part messages causes an indefinite hang (function never returns).

Tried: PHP-5.0.3, PHP-5.0.4, PHP-5.0.5-dev
c-client: imap-2004d
Apache: httpd-2.0.53

I gave a look at other related bugs, and checkd that que imap link was still up when the function was called. I also tried to place a timer between two function calls.
Nothing worked, the link is still up when que function hangs.

Reproduce code:
$pop_user = "someuser";
$pop_pass = "somepassword";
$pop_host = "";
$mbox_path = "/path/to/failedmsg.1";
$pop_conn_string = "\{$pop_host:143/imap}$mbox_path";
$pop_conn = imap_open($pop_conn_string, $pop_user, $pop_pass);
// Assuming message-of-death is first one in the mbox
$mimeobj = imap_fetchstructure($pop_conn, 1);
// Never gets here...

Expected result:
imap_fetchstructure() should quickly return the structure of the

Actual result:
The function never returns on most mails, and page loading stops.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-18 00:45 UTC]
If the problem persists, please provide a URL to the complete text of the message that causes the hang.
 [2005-06-20 09:51 UTC] benjamin dot malynovytch at libertic dot fr
I tried several versions of imap (UW): imap-2001a, imap-2002a, imap-2004a, imap-2004d, imap-2004e-DEVEL
None of them worked.

I'm afraid their's no error log: the application hangs without returning anything (would be too easy to debug).
The only thing I know, is that the application hangs just after the call to "imap_fetchstructure" (did some echo "..."; flush(); to be sure).

Any idea ?
 [2005-06-20 11:54 UTC]
We're interested in the 'message-of-death' only. Just export that message and put it online or send via email to and

Your initial example script is a bit odd though,
what EXACTLY (for real!) is $mbox_path set to? 

 [2005-06-20 15:11 UTC] benjamin dot malynovytch at libertic dot fr
iliaa and sniper, you'll find the asked informations in your mailboxes.

Is it possible that php5 doesn't work properly, when php4 does ?
It tried the application on an "old" box, using php4(4.3.4), and it works fine (even on the message-of-death).
I haven't tried out on the production box though, cause I can't swap so easily on php4 (other applications will dropp).

I also noticed, that a similar bug had been corrected in php 4.0.4 (imap_fetchstructure crashing) (Changelog). Is it possible that php5 has the same bug again ?
 [2005-06-20 16:01 UTC] root at ka-rel dot cz
I'm experiencing the same behaviour with certain messages (mostly spam but not always). A sample message is located at

Whenever imap_fetchstructure function tries to analyze the message, cpu gets to 100% and hangs (on NT 4.0 Server) or displays the "crash message" (on WinXP), requesting to send it to Microsoft.

Till now, I've noticed that the bad messages have improperly set boundary strings - maybe this confuses the function and results to unability to parse individual parts of message. Also, such messages are not decoded correctly if opened in a mail client.

PHP 4.3.3
IMAP c-Client Version 2001
WinXP: php_imap.dll, 593920 bytes, 24th August 2003
WinNT: php_imap.dll, 602112 bytes,  6th June   2005
 [2005-09-07 04:24 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The problem lies in the c-client lib that does not handle improperly formatted multi-part e-mails without valid terminators.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 02:01:32 2024 UTC