In sqimap_logout, check if we have a stream to logout to.
[squirrelmail.git] / functions / imap_general.php
index 008d0053231e4da30235e64312ac398d132ab99a..a34afc251e1792afc2acb85fccbe64f2d46efae2 100755 (executable)
@@ -257,8 +257,10 @@ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $
 
 /* Simply logs out the IMAP session */
 function sqimap_logout ($imap_stream) {
-    /* Logout is not valid until the server returns 'BYE' */
-    sqimap_run_command($imap_stream, 'LOGOUT', false, $response, $message);
+    /* Logout is not valid until the server returns 'BYE'
+     * If we don't have an imap_ stream we're already logged out */
+    if(isset($imap_stream))
+        sqimap_run_command($imap_stream, 'LOGOUT', false, $response, $message);
 }
 
 function sqimap_capability($imap_stream, $capability='') {