Bug #18282 Updated: imap_open return doesn't return FALSE when mailbox doesn't exist
| From: | valerio at dei dot unipd dot it | Date: | Fri, 12 Jul 2002 09:20:42 +0000 |
| Subject: | Bug #18282 Updated: imap_open return doesn't return FALSE when mailbox doesn't exist | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13931@lists.php.net to get a copy of this message | ||
ID: 18282
Updated by: valerio@dei.unipd.it
Reported By: valerio@dei.unipd.it
Status: Bogus
Bug Type: IMAP related
Operating System: Linux
PHP Version: 4.2.1
New Comment:
Sorry, but I don't think so.
The function names are imap_open() and imap_reopen not imap_connect().
If mailbox doesn't exist imap_lasterror() return an useless nil.
During an IMAP transaction when you act a "SELECT" on a
unexisting mailbox you get an error:
. select alskj
. NO SELECT failed: Can't open mailbox alskj: no such mailbox
Probably there is a weakness in how open_mail() in lib c-client return
streams.
Talking about my workaround ... suppose you have thousands
of mailbox...it's not so optimized to check all of them just to open
one.
Then suppose that between imap_listbox and imap_reopen the file
vanished. What would you get? The script output an empty page.
Regards
Valerio
Previous Comments:
------------------------------------------------------------------------
[2002-07-12 04:32:54] sniper@php.net
Your 'workaround' really is the correct way to do it..
In your test script, the connection is established,
just the mailbox select fails.
Try add this right after the imap_open() line:
echo imap_last_error();
------------------------------------------------------------------------
[2002-07-12 04:22:25] valerio@dei.unipd.it
This script output nothing (I mean _nothing_) when mailbox
with name "this_file_doesnt_exist" isn't there.
<?php
print "BEFORE IMAP_OPEN<br>";
$my_stream=imap_open("{localhost:143}this_file_doesnt_exist","realusername",
"rightpassword",OP_READONLY);
if ($my_stream) {
/* uncomment me if you want to see $my_stream value */
/*print $my_stream; */
$barney=imap_fetchbody($my_stream,1,"1");
print $barney;
imap_close($my_stream);
}
print "AFTER IMAP_OPEN<br>";
?>
My current workaround is a
imap_open("{localhost:143}",...,OP_HALFOPEN), imap_listmailbox and
comparison on all values to check the existence of a particular mailbox
name before opening it.
------------------------------------------------------------------------
[2002-07-11 14:21:35] sniper@php.net
Please give us a short but complete example script
which can be used to reproduce this..
------------------------------------------------------------------------
[2002-07-11 14:12:23] valerio@dei.unipd.it
imap_open($server_strings.$mailbox, $username,$passwd,$options)
should return FALSE when username/password are correct
but mailbox doesn't exist.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18282&edit=1