php.net |  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
Votes:4
Avg. Score:4.0 ± 1.7
Reproduced:3 of 4 (75.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: marco@php.net Assigned:
Status: Open Package: IMAP related
PHP Version: 7.3.6 OS: OS X 10.14
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marco@php.net
New email:
PHP Version: OS:

 

 [2019-06-13 14:38 UTC] marco@php.net
Description:
------------
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:
---------------
<?php
$handle=imap_open('{imap.example.net:993/imap/ssl/novalidate-cert/debug}INBOX','user','pass');

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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-13 14:45 UTC] marco@php.net
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] cmb@php.net
> 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] cmb@php.net
-Type: Bug +Type: Feature/Change Request
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 18:01:31 2024 UTC