PHP Classes

trying to connect to localhost

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  trying to connect to localhost  >  (Un) Subscribe thread alerts  
Subject:trying to connect to localhost
Summary:I am trying to open a gmail mailbox, tries to open localhost
Messages:5
Author:william drescher
Date:2009-06-28 11:40:53
Update:2009-06-30 10:44:12
 

  1. trying to connect to localhost   Reply   Report abuse  
Picture of william drescher william drescher - 2009-06-28 11:40:53
my code:

$pop3=new pop3_class;
$pop3->hostname="pop.gmail.com"; */
$pop3->port=995;
$pop3->tls=1;

but the test script complains:
Connecting to localhost ...
Error: 111 could not connect to the host "localhost": Connection refused

I have no idea where it gets "localhost" as it is not in the test program or the class.

help

  2. Re: trying to connect to localhost   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-06-28 17:40:19 - In reply to message 1 from william drescher
It is hard to tell without seeing the whole script. Maybe you are resetting the hostname variable to localhost elsewhere before opening the connection.

  3. Re: trying to connect to localhost   Reply   Report abuse  
Picture of william drescher william drescher - 2009-06-29 12:38:07 - In reply to message 2 from Manuel Lemos
AFAIK, I made no changes to the test script other than to fill in the server, user and password
<?php
/*
* test_pop3.php
*
* @(#) $Header: /home/mlemos/cvsroot/pop3/test_pop3.php,v 1.7 2006/06/11 14:52:09 mlemos Exp $
*
*/

?><HTML>
<HEAD>
<TITLE>Test for Manuel Lemos's PHP POP3 class</TITLE>
</HEAD>
<BODY>
<?php

require("pop3.php");

/* Uncomment when using SASL authentication mechanisms */
require("../sasl-2005-10-31/sasl.php");

$pop3=new pop3_class;
$pop3->hostname="pop.gmail.com";
$pop3->port=995;
$pop3->tls=1;
$user="**mailbox@gmail.com**";
$password="**password**";
$pop3->realm="";
$pop3->workstation="";
$apop=0;
/* SASL authentication mechanism */
$pop3->debug=1;
$pop3->html_debug=1;
$pop3->join_continuation_header_lines=1;

if(($error=$pop3->Open())=="")
{
echo "<PRE>Connected to the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
if(($error=$pop3->Login($user,$password,$apop))=="")
{
echo "<PRE>User &quot;$user&quot; logged in.</PRE>\n";
if(($error=$pop3->Statistics($messages,$size))=="")
{
echo "<PRE>There are $messages messages in the mail box with a total of $size bytes.</PRE>\n";
$result=$pop3->ListMessages("",0);
if(GetType($result)=="array")
{
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result)," - ",$result[Key($result)]," bytes.</PRE>\n";
$result=$pop3->ListMessages("",1);
if(GetType($result)=="array")
{
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result),", Unique ID - \"",$result[Key($result)],"\"</PRE>\n";
if($messages>0)
{
if(($error=$pop3->RetrieveMessage(1,$headers,$body,2))=="")
{
echo "<PRE>Message 1:\n---Message headers starts below---</PRE>\n";
for($line=0;$line<count($headers);$line++)
echo "<PRE>",HtmlSpecialChars($headers[$line]),"</PRE>\n";
echo "<PRE>---Message headers ends above---\n---Message body starts below---</PRE>\n";
for($line=0;$line<count($body);$line++)
echo "<PRE>",HtmlSpecialChars($body[$line]),"</PRE>\n";
echo "<PRE>---Message body ends above---</PRE>\n";
if(($error=$pop3->DeleteMessage(1))=="")
{
echo "<PRE>Marked message 1 for deletion.</PRE>\n";
if(($error=$pop3->ResetDeletedMessages())=="")
{
echo "<PRE>Resetted the list of messages to be deleted.</PRE>\n";
}
}
}
}
if($error==""
&& ($error=$pop3->Close())=="")
echo "<PRE>Disconnected from the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";

}
else
$error=$result;
}
else
$error=$result;
}
}
}
if($error!="")
echo "<H2>Error: ",HtmlSpecialChars($error),"</H2>";
?>

</BODY>
</HTML>

  4. Re: trying to connect to localhost   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-06-30 05:58:10 - In reply to message 3 from william drescher
This is odd because the error message that you shown uses the hostname variable and it shows localhost and not pop.gmail.com . Are you sure you did not changed it inadvertently?

  5. Re: trying to connect to localhost   Reply   Report abuse  
Picture of william drescher william drescher - 2009-06-30 10:44:12 - In reply to message 4 from Manuel Lemos
YOu are correct - I discovered that the file on the server was out of syncronization with the file I edited.
I will try again