[imp] IMAP login code

Stephen A. Cochran Lists stephen.a.cochran.lists at cahir.net
Mon Apr 17 00:29:38 PDT 2006


On Apr 17, 2006, at 3:13 AM, Stephen A. Cochran Lists wrote:

> In IMP-4.1.1 lib/IMAP/Client.php on line 561, the generic IMAP  
> login is handled with the following code:
>
>         case 'login':
>             $tag = $this->_generateSid();
>             $query = $tag . " LOGIN $username {" . strlen 
> ($password) . "}\r\n";
>             fwrite($this->_stream, $query);
>             $read = $this->_fgets();
>             if (substr($read, 0, 1) == '+') {
>                 fwrite($this->_stream, "$password\r\n");
>                 $read = $this->_fgets();
>             } else {
>                 return PEAR::raiseError(_("Unexpected response from  
> server to LOGIN command."), 'horde.error');
>             }
>             break;



Two more problems. I can find no reference in the RFC to providing  
the password length with the LOGIN command and then sending the  
password later. Also, the line fails with a username with spaces,  
which are valid according to the spec (and used on our mail server).  
The $username should be quoted when sent to the server to accommodate  
this:

$query = $tag . " LOGIN \"$username\" $password\r\n";

The above line fixes the login with our IMAP server. Not sure why the  
IMP moved away from using the IMAP support in php provided by c- 
client, but it seems that some functionality was lost.

Steve Cochran 


More information about the imp mailing list