|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #78158 imap_open does not respect OP_DEBUG or /debug
Submitted: 2019-06-13 14:38 UTC Modified: 2020-10-14 13:51 UTC
Avg. Score:4.0 ± 1.7
Reproduced:3 of 4 (75.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: Assigned:
Status: Open Package: IMAP related
PHP Version: 7.3.6 OS: OS X 10.14
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:
New email:
PHP Version: OS:


 [2019-06-13 14:38 UTC]
When calling imap_open with either OP_DEBUG as flag or by specifying /debug in the mailbox string, there is no debug output.

This is especially bad when trying to troubleshoot situations like Exchange servers accessed over SSL as the connection cannot be monitored by Wireshark or other monitors without significant effort.

Test script:

Expected result:
Expecting on stdout (or in a callback) the communication to/from the IMAP server.

Actual result:
Only the error message (e.g. "AUTHENTICATE failed") is visible via imap_error.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-13 14:45 UTC]
The actual root cause is that c-client, the library behind the imap extension, uses a callback ("mm_dlog") to pass the connection debug log to the application.

mm_dlog is defined in ext/imap/php_imap.c:5077 (in current master) and is a no-op at the moment. I propose extending the imap extension API to include a function "imap_debug_callback" accepting a userland function with a single string parameter. Now, when mm_dlog gets called, the imap extension checks if a callback has been registered; if not a E_WARNING gets raised (text e.g. "IMAP mm_dlog got called without registering a callback in imap_debug_callback before"), if yes the callback gets called.

This way, simple applications can have the callback simple ("function xxx($line) { echo $line."\n"; }"), while more complex applications such as the php-imap shim and its Symfony wrapper secit-pl/imap-bundle can use the PSR logging mechanisms.
 [2020-10-14 13:50 UTC]
> I propose extending the imap extension API to include a function
> "imap_debug_callback" accepting a userland function with a single
> string parameter.

That seems to be reasonable.  A pull request would be welcome!
 [2020-10-14 13:51 UTC]
-Type: Bug +Type: Feature/Change Request
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 15:01:28 2024 UTC