could'nt open stream

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bouboul
Forum Commoner
Posts: 28
Joined: Sat Oct 25, 2003 4:08 am

could'nt open stream

Post 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 ?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

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

Code: Select all

$MAILSERVER="{localhost:143}";
bouboul
Forum Commoner
Posts: 28
Joined: Sat Oct 25, 2003 4:08 am

could'nt open stream

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

and there is an imap-server listening on localhost:143 ?
bouboul
Forum Commoner
Posts: 28
Joined: Sat Oct 25, 2003 4:08 am

couldn't open stream

Post by bouboul »

how can i make sure that there's an imap-server listening on localhost:143 ?
which command do i have to type ?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
bouboul
Forum Commoner
Posts: 28
Joined: Sat Oct 25, 2003 4:08 am

couldn't open stream

Post 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!!!!!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
bouboul
Forum Commoner
Posts: 28
Joined: Sat Oct 25, 2003 4:08 am

couln't open stream

Post 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
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

like the warning tells => is $num defined? check it?
bouboul
Forum Commoner
Posts: 28
Joined: Sat Oct 25, 2003 4:08 am

could'nt open stream

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
bouboul
Forum Commoner
Posts: 28
Joined: Sat Oct 25, 2003 4:08 am

couldn't open stream

Post 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 ?
Post Reply