argument is not a valid imap resource

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I would like to access (open) my remote IMAP Mailbox with the
imap_open() function in PHP Version 5.0.4. The Mailbox is located at
the german provider

The imap_open() function does not produce an error message as you can
see below. But when I call the imap_headers() function the warning
message mentioned in the subject as well as below is returned.

Access to the same Mailbox with my mail/news programm gnus works.

I monitored the communication between my computer and freenet while I
was accessing the mailbox using gnus and while I tryed to access it
with the php script. I used tethereal for doing this. There is a
difference between the communication logs that could be
important. Using the php Script a relevant part of the communication
looks like this:

- PHP sends (Frame 21)
Internet Message Access Protocol
    00000003 SELECT inbox.fab\r\n
        Request Tag: 00000003
        Request: SELECT inbox.fab

- freenet sends (Frame 22)
Internet Message Access Protocol
    * FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)\r\n
        Response Tag: *
        Response: FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)

- PHP sends (Frame 23)
    00000004 LOGOUT\r\n
        Request Tag: 00000004
        Request: LOGOUT

- freenet sends (Frame 24)
    * BYE Courier-IMAP server shutting down\r\n
        Response Tag: *
        Response: BYE Courier-IMAP server shutting down

Why does PHP send the "Request: LOGOUT" in Frame 23? Is that normal
behaviour? I am asking because the communication between gnus and
freenet differs from the communication shown above. I show you a small
part of this conversation as well.

- gnus sends (Frame 95)
Internet Message Access Protocol
    4 SELECT "inbox.fab"\r\n
        Request Tag: 4
        Request: SELECT "inbox.fab"

- freenet sends (Frame 96)
    * FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)\r\n
        Response Tag: *
        Response: FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)

- gnus sends (Frame 98) (Frame 97 does not have anything to do with IMAP)
        Request Tag: 5

- freenet sends
    * SEARCH\r\n
        Response Tag: *
        Response: SEARCH

- and so on ...

Obviously gnus does not send the LOGOUT request after receiving the

Further information that I consider relevant follows at the end of
this message.

Thanx very much in advance for any hints.

Greetings, Fabian Mller

php code
$inbox = imap_open("inbox.fab", "UserName", "Password") ||
if ($inbox == false) {
    echo "problem<br>";
 } else {
    echo "great<br>";
$mails = imap_headers($inbox);

output in my browser
Warning: imap_headers(): supplied argument is not a valid imap resource in
mail_first.php on line 8

phpinfo() shows this among other things
'./configure' '--with-apxs2=/opt/httpd-2.0.54/bin/apxs'
              '--with-libxml-dir=[Path to libxml2]'

Registered Stream Socket Transports: tcp, udp, unix, udg

Loaded Modules: mod_imap is listed

The info box about imap says that I have IMAP c-Client Version 2004

Re: argument is not a valid imap resource

Fabian Mller,

My suggestion on this imap problem would be to take a look at the open
source projects and see how there implementation works.  See if it is
the same thing and works.

This is always a good place to start if you can't get a certain type of
thing to work.


Site Timeline