|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 01:00:02 2025 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.