Page 1 of 1

could'nt open stream

Posted: Sat Oct 25, 2003 4:08 am
by bouboul
i'm constantly getting the following :

Warning: Couldn't open stream {localhost/imap : 143} in /usr/local/httpd/htdocs/view.php on line 5

Warning: imap_header(): supplied argument is not a valid imap resource in /usr/local/httpd/htdocs/view.php on line 6
From:
To:
Date:
Subject:


Warning: imap_body(): supplied argument is not a valid imap resource in /usr/local/httpd/htdocs/view.php on line 12

when i'm trying the following portions of codes :
<?php
$MAILSERVER="{localhost/imap : 143}";
$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW);
$header=imap_header($link,$num);

echo "From: $header[fromaddress]<br>";
echo "To: $header[toaddress]<br>";
echo "Date: $header[Date]<br>";
echo "Subject: $header[Subject]<br><br>";
echo imap_body($link,$num);

?>
could anyone help me ?

Posted: Sat Oct 25, 2003 4:52 am
by volka
try

Code: Select all

$MAILSERVER="{localhost:143/imap}";
or

Code: Select all

$MAILSERVER="{localhost:143}";

could'nt open stream

Posted: Sun Oct 26, 2003 9:32 am
by bouboul
hello, i've made the change

$MAILSERVER="{localhost:143/imap}";
$MAILSERVER="{localhost:143}";

nothing is really changing, i'm getting the same thing :

Warning: Couldn't open stream {localhost:143/imap} in /usr/local/httpd/htdocs/view.php on line 5

Warning: imap_header(): supplied argument is not a valid imap resource in /usr/local/httpd/htdocs/view.php on line 6
From:
To:
Date:
Subject:


Warning: imap_body(): supplied argument is not a valid imap resource in /usr/local/httpd/htdocs/view.php on line 12

what to do , i really seem confused

thanx

Posted: Sun Oct 26, 2003 9:42 am
by volka
and there is an imap-server listening on localhost:143 ?

couldn't open stream

Posted: Mon Oct 27, 2003 1:17 am
by bouboul
how can i make sure that there's an imap-server listening on localhost:143 ?
which command do i have to type ?

Posted: Mon Oct 27, 2003 8:15 am
by volka
/usr/local/httpd/htdocs/view.php
so I take it you're on a unix-style maschine. If you have access to the console try netstat -l
It should list all listening socket, something like

Code: Select all

Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 *:netbios-ssn           *:*                     LISTEN      
tcp        0      0 *:www                   *:*                     LISTEN      
tcp        0      0 *:ssh                   *:*                     LISTEN
the Address field might contain a numerical value or the name of the well-known port (as above). If your imap-server is listening it should be listed there.

couldn't open stream

Posted: Tue Oct 28, 2003 1:51 am
by bouboul
here is the output of netstat -l :

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:imaps *:* LISTEN
tcp 0 0 *:imap *:* LISTEN
...
tcp 0 0 *:ssh *:* LISTEN
...
[mod_edit: removed most of the ports. It's not "necessary" everyone knows what's running on your box ;) ]

what i have to do know?

thanx extreme guru!!!!!

Posted: Tue Oct 28, 2003 6:24 am
by volka
ah ok, then there is an imap-server.
the imap extension seems to put two messages if the open() function fails. One error and one warning; sorry my fault ;)

so hopefully this one

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
$MAILSERVER="{localhost:143}INBOX";
$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW); 
...
?>
will give you a more detailed description of the error.

couln't open stream

Posted: Wed Oct 29, 2003 2:39 am
by bouboul
hello extreme guru,

i've just been adding the lines you advised me to add , the code is :

<?php
$PHP_AUTH_USER="root";
$PHP_AUTH_PW="";
error_reporting(E_ALL);
ini_set("display_errors",TRUE);
$MAILSERVER="{localhost:143}INBOX";
$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW);
$header=imap_header($link,$num);

echo "From: $header[fromaddress]<br>";
echo "To: $header[toaddress]<br>";
echo "Date: $header[Date]<br>";
echo "Subject: $header[Subject]<br><br>";
echo imap_body($link,$num);

?>

and i'm getting the following result :

Warning: Couldn't open stream {localhost:143}INBOX in /usr/local/httpd/htdocs/view.php on line 7

Notice: Undefined variable: num in /usr/local/httpd/htdocs/view.php on line 8

Warning: imap_header(): supplied argument is not a valid imap resource in /usr/local/httpd/htdocs/view.php on line 8
From:
To:
Date:
Subject:


Notice: Undefined variable: num in /usr/local/httpd/htdocs/view.php on line 14

Warning: imap_body(): supplied argument is not a valid imap resource in /usr/local/httpd/htdocs/view.php on line 14

Notice: Certificate failure for localhost: self signed certificate: /C=--/ST=SomeState/L=SomeCity/O=SomeOrganization/OU=SomeOrganizationalUnit/CN=localhost.localdomain/emailAddress=root@localhost.localdomain (errflg=2) in Unknown on line 0

what is really the problem?

thanx for your help

Posted: Wed Oct 29, 2003 3:41 am
by mudkicker
like the warning tells => is $num defined? check it?

could'nt open stream

Posted: Wed Oct 29, 2003 6:35 am
by bouboul
i'm going to check $num variable. but why i'm constantly getting
the message : couldn't open stream online 7, while the imap server seems to work.

what does the following mean ?.

Notice: Certificate failure for localhost: self signed certificate: /C=--/ST=SomeState/L=SomeCity/O=SomeOrganization/OU=SomeOrganizationalUnit/CN=localhost.localdomain/emailAddress=root@localhost.localdomain (errflg=2) in Unknown on line 0

thanx 4 your help

Posted: Wed Oct 29, 2003 8:31 am
by volka
hm, unsure but did you check out the user contributed note from russell at flora dot ca at http://php.net/imap_open?

couldn't open stream

Posted: Tue Nov 04, 2003 1:26 am
by bouboul
hello,

it seems that imapd is not starting, when i'm doing pgrep imapd i cannot see any process, while i've alreay restarted the xinetd.


what can i do ?