By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,732 Members | 1,461 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,732 IT Pros & Developers. It's quick & easy.

argument is not a valid imap resource

P: n/a
Hello,

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 freenet.de.

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)
5 UID SEARCH UNSEEN UNDELETED\r\n
Request Tag: 5
Request: UID SEARCH UNSEEN UNDELETED

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

- and so on ...

Obviously gnus does not send the LOGOUT request after receiving the
FLAGS.

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

Thanx very much in advance for any hints.

Greetings, Fabian Müller

php code
--------
$inbox = imap_open("{mx.freenet.de:143}inbox.fab", "UserName", "Password") || die(imap_errors());;
if ($inbox == false) {
echo "problem<br>";
} else {
echo "great<br>";
}
$mails = imap_headers($inbox);

output in my browser
--------------------
great
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-mysql=/usr/local/mysql-standard-4.0.20-pc-linux-i686'
'--with-libxml-dir=[Path to libxml2]'
'--without-iconv'
'--with-imap=/usr/local/imap-2004d/'

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
installed.
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Fabian Müller,

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.

Mike
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.