- (let ((result (nnimap-command "LOGIN %S %S"
- (car credentials) (cadr credentials))))
- (unless (car result)
- (delete-process (nnimap-process nnimap-object))
- (error "Unable to login to the server: %s"
- (mapconcat #'identity (cadr result) " ")))
- (setf (nnimap-capabilities nnimap-object)
- (or (nnimap-find-parameter "CAPABILITY" (cdr result))
- (nnimap-find-parameter
- "CAPABILITY" (cdr (nnimap-command "CAPABILITY")))))
- (when (member "QRESYNC" (nnimap-capabilities nnimap-object))
- (nnimap-command "ENABLE QRESYNC"))
- t)))))
+ (when (setq connection-result (nnimap-wait-for-connection))
+ (unless (equal connection-result "PREAUTH")
+ (if (not (setq credentials
+ (nnimap-credentials nnimap-address ports)))
+ (setq nnimap-object nil)
+ (setq login-result (nnimap-command "LOGIN %S %S"
+ (car credentials)
+ (cadr credentials)))
+ (unless (car login-result)
+ (delete-process (nnimap-process nnimap-object))
+ (setq nnimap-object nil))))
+ (when nnimap-object
+ (setf (nnimap-capabilities nnimap-object)
+ (mapcar
+ #'upcase
+ (or (nnimap-find-parameter "CAPABILITY" (cdr login-result))
+ (nnimap-find-parameter
+ "CAPABILITY" (cdr (nnimap-command "CAPABILITY"))))))
+ (when (member "QRESYNC" (nnimap-capabilities nnimap-object))
+ (nnimap-command "ENABLE QRESYNC"))
+ t))))))