@ -145,12 +145,8 @@ ImapConnection.prototype.connect = function(loginCb) {
} ) ;
state . conn . on ( 'ready' , function ( ) {
// First get pre-auth capabilities, including server-supported auth
// mechanisms
self . _send ( 'CAPABILITY' , function ( ) {
// Next, attempt to login
var checkedNS = false ;
self . _login ( function redo ( err ) {
var redo = function ( err ) {
if ( err )
return loginCb ( err ) ;
// Next, get the list of available namespaces if supported (RFC2342)
@ -163,7 +159,18 @@ ImapConnection.prototype.connect = function(loginCb) {
// Lastly, get the top-level mailbox hierarchy delimiter used by the
// server
self . _send ( 'LIST "" ""' , loginCb ) ;
} ) ;
} ;
// First, get the supported (pre-auth or otherwise) capabilities:
self . _send ( 'CAPABILITY' , function ( ) {
// No need to attempt the login sequence if we're on a PREAUTH
// connection.
if ( state . status != STATES . AUTH ) {
// First get pre-auth capabilities, including server-supported auth
// mechanisms
self . _login ( redo ) ;
} else {
redo ( ) ;
} ;
} ) ;
} ) ;