[imp] Re: IMP connects twice to POP server

Carlton Thomas carlton@gifford.co.uk
Tue, 2 Apr 2002 10:37:35 +0100 (GMT/BST)


Chuck,

Thanks for your response. However, my comments re: the number of
accesses to the server was just a passing comment and I was not
looking for an answer to that question.

My main question was related to the almost simultaneous access to
the POP server which will cause IMP to fail to authenticate. I have
looked at the PHP code and suggest that some re-try logic be added
to attempt the connection again in the event of a failure. I have
done this myself and have eliminated the problem i was experiencing.

What I did was to replace the the statements which connect to the
server in "imp/lib/IMP.php" with the following:-

        /**
        * If the imap_open fails, this may be due to a transient error, so just
        *  retry the operation. If it still fails after the attempts then give up
        */
        $timer = 0;
        $imp['stream'] = false;
        while ($timer < 5 && !$imp['stream']) {
            if ($flags == 0) {
                $imp['stream'] = @imap_open($connstr, $imp['user'], Secret::read(Secret::getKey('imp'), $imp['pass']));
            } else {    
                $imp['stream'] = @imap_open($connstr, $imp['user'], Secret::read(Secret::getKey('imp'), $imp['pass']), $flags);    
            }    
            if (!$imp['stream']) {
                sleep (1);
            }
        }


I am not sure what the max value of the loop counter should be,
however, five seems OK for the tests I did. Will this fragment
of code help others who may be experiencing the same or similar
problems?

Now that I got it working, there are a number of other little
problems, but I will create new threads for those.

Thanks again for your reply and thanks for your efforts in
creating this great product.

Regards !

--
Carlton
=============================
GIFFORD INTERNET SERVICES
Bristol, United Kingdom 
Tel: 0845 111 0032
Tel: 0117 939 7722
Fax: 0845 111 0033
Email: admin@gifford.co.uk
Web: http://www.gifford.co.uk
=============================


On Tue, 26 Mar 2002, Chuck Hagenbuch wrote:

> Quoting Carlton Thomas <carlton@gifford.co.uk>:
> 
> > The downside of this mod, is that IMP is less responsive, since it has
> > to delay for 2 seconds before every access to the POP server. Talking
> > of access to the POP server, wow!!!, why does IMP need to talk to the
> > server so often?
> 
> Because PHP has no provision for persistant connections to POP and IMAP 
> servers, so we need to reconnect on every page load in which we need to do 
> something. This has been discussed in depth on the list in the past, 
> several times... 
> 
> -chuck
> 



>From boiboi@stberlin.com Date: Tue,  2 Apr 2002 17:49:46 +0800
Return-Path: <boiboi@stberlin.com>
Mailing-List: contact imp-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list imp@lists.horde.org
Received: (qmail 97410 invoked from network); 2 Apr 2002 09:49:53 -0000
Received: from unknown (HELO stberlin.com) (216.12.219.9)
  by clark.horde.org with SMTP; 2 Apr 2002 09:49:53 -0000
Received: (qmail 32077 invoked by uid 0); 2 Apr 2002 09:49:46 -0000
Received: from 216.101.187.113 ( [216.101.187.113])
	as user boiboi@localhost by www.stberlin.com with HTTP;
	Tue,  2 Apr 2002 17:49:46 +0800
Message-ID: <1017740986.3ca97ebac5995@www.stberlin.com>
Date: Tue,  2 Apr 2002 17:49:46 +0800
From: boiboi alavaren <boiboi@stberlin.com>
To: imp@lists.horde.org
References: <1017561611.3ca6c20b1ab2a@www.stberlin.com> <1017679130.3ca88d1a33321@marina.horde.org>
In-Reply-To: <1017679130.3ca88d1a33321@marina.horde.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 3.1-cvs
X-Originating-IP: 216.101.187.113
Subject: Re: [imp] Login form on non-imp page...

I can't seem to login and it redirects to imp/login.php with the following error

login.php?1=1&imapuser=myusername&server=imap&reason=failed


is there any other files i have to change besides the to change besides 
customize_login.php    ?

----------------------------

// CUSTOMIZE THIS
define('IMP_BASE', '..');

require_once IMP_BASE . '/lib/base.php';
require_once IMP_BASE . '/config/servers.php';

/* Set up the password encryption token. */
Secret::setKey('imp');

/* Use the first server defined in servers.php. */
// CUSTOMIZE THIS
$server = key($servers);

?>

<!-- CUSTOMIZE THIS -->
<form action="<?= Horde::applicationUrl('redirect.php') ?>" method="post">
User: <input name="imapuser" tabindex="1" type="text" size="20" /><br />
Pass: <input name="pass" tabindex="2" type="password" size="20" /><br />
<input type="hidden" name="server" value="<?= $server ?>" />
<input type="submit" value="Log in" />
</form>


--------------------------------



Quoting Chuck Hagenbuch <chuck@horde.org>:

+ Quoting boiboi alavaren <boiboi@stberlin.com>:
+ 
+ > Hi, has anyone created a login form outside of the imp directory? I need
+ > to know what action to put when the form is submitted. 
+ 
+ See imp/scripts/custom_login.php.




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/