Index: branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3380)
+++ branches/2.2/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 3385)
@@ -50,10 +50,13 @@
 	}
 	// BEGIN of functions.
-	function open_mbox($folder = False)
+	function open_mbox($folder = False,$force_die=true)
 	{
 		if (is_resource($this->mbox))
 			return $this->mbox;
 		$folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1");
-	 	$this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error()))));
+			 	if($force_die) 
+			$this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error()))));
+		else 
+			$this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password);
 		return $this->mbox;
 	 }
Index: branches/2.2/expressoMail1_2/inc/hook_home.inc.php
===================================================================
--- branches/2.2/expressoMail1_2/inc/hook_home.inc.php	(revision 3018)
+++ branches/2.2/expressoMail1_2/inc/hook_home.inc.php	(revision 3385)
@@ -33,70 +33,84 @@
 		$_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
 		$expressoMail	= CreateObject($current_app.'.imap_functions');
-		$mbox_stream = $expressoMail-> open_mbox(); 		
-		$messages	 = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID, UNSEEN);
-		$num_new_messages = count($messages);
-		$subjects = array();
-		
-		foreach($messages as $idx => $message){
-			if($idx == 10){
-				break;
+		$mbox_stream = $expressoMail-> open_mbox(False,false); 		
+		if(!$mbox_stream) {
+			$portalbox = CreateObject('phpgwapi.listbox',
+				Array(
+					'title'     => "<font color=red>".lang('Connection failed with %1 Server. Try later.',lang('Mail'))."</font>",
+					'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+					'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+					'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+					'width'     => '100%',
+					'outerborderwidth' => '0',
+					'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
+				)
+			);
+		}
+		else {
+			$messages	 = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID, UNSEEN);
+			$num_new_messages = count($messages);
+			$subjects = array();
+			
+			foreach($messages as $idx => $message){
+				if($idx == 10){
+					break;
+				}
+				$header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream,$message), 80, 255);
+				if (!is_object($header))
+					return false;			
+	
+				$date_msg = date("d/m/Y",$header->udate);
+				if (date("d/m/Y") == $date_msg)
+					$date = date("H:i",$header->udate);
+				else
+					$date = $date_msg;
+					
+				$subject = $expressoMail->decode_string($header->fetchsubject);				
+				$text = "<div style='overflow:hidden;white-space:nowrap'>".$date." .: ".$subject."</div>";
+				if(strlen($text) > 105)
+					$text = substr($text,0,105).' ...';
+			
+				$link_msg = $GLOBALS['phpgw']->link(
+						'/'.$current_app.'/index.php',
+						'msgball[msgnum]='.$message.'&msgball[folder]=INBOX');
+				$data[] = array('text' => $text, 'link' => $link_msg);					
 			}
-			$header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream,$message), 80, 255);
-			if (!is_object($header))
-				return false;			
-
-			$date_msg = date("d/m/Y",$header->udate);
-			if (date("d/m/Y") == $date_msg)
-				$date = date("H:i",$header->udate);
-			else
-				$date = $date_msg;
-				
-			$subject = $expressoMail->decode_string($header->fetchsubject);				
-			$text = "<div style='overflow:hidden;white-space:nowrap'>".$date." .: ".$subject."</div>";
-			if(strlen($text) > 105)
-				$text = substr($text,0,105).' ...';
-		
-			$link_msg = $GLOBALS['phpgw']->link(
-					'/'.$current_app.'/index.php',
-					'msgball[msgnum]='.$message.'&msgball[folder]=INBOX');
-			$data[] = array('text' => $text, 'link' => $link_msg);					
-		}
-				
-		imap_close($mbox_stream);
-		
-		$title = $current_name." - ".($num_new_messages > 1 ? lang("You have %1 new messages!","<font color=red>".$num_new_messages."</font>") : ($num_new_messages == 1 ? str_replace("1","<font color=red>1</font>",lang("you have 1 new message!")) : lang("you have no new messages")));			
-		$GLOBALS['phpgw']->translation->add_app($current_app);
-
-		if ((isset($prev_currentapp)) && ($prev_currentapp)	&& ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp))		
-			$GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp;
-		
-		$portalbox = CreateObject('phpgwapi.listbox',
-			Array(
-				'title'     => $title,
-				'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
-				'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
-				'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
-				'width'     => '100%',
-				'outerborderwidth' => '0',
-				'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
-			)
-		);
-
-		$app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail');
-		$GLOBALS['portal_order'][] = $app_id;
-
-		$var = Array(
-			'up'       => Array('url' => '/set_box.php', 'app' => $app_id),
-			'down'     => Array('url' => '/set_box.php', 'app' => $app_id),
-			'close'    => Array('url' => '/set_box.php', 'app' => $app_id),
-			'question' => Array('url' => '/set_box.php', 'app' => $app_id),
-			'edit'     => Array('url' => '/set_box.php', 'app' => $app_id)
-		);
-
-		while(list($key,$value) = each($var))		
-			$portalbox->set_controls($key,$value);
-
-		$portalbox->data = $data;
 					
+			imap_close($mbox_stream);
+			
+			$title = $current_name." - ".($num_new_messages > 1 ? lang("You have %1 new messages!","<font color=red>".$num_new_messages."</font>") : ($num_new_messages == 1 ? str_replace("1","<font color=red>1</font>",lang("you have 1 new message!")) : lang("you have no new messages")));			
+			$GLOBALS['phpgw']->translation->add_app($current_app);
+	
+			if ((isset($prev_currentapp)) && ($prev_currentapp)	&& ($GLOBALS['phpgw_info']['flags']['currentapp'] != $prev_currentapp))		
+				$GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp;
+			
+			$portalbox = CreateObject('phpgwapi.listbox',
+				Array(
+					'title'     => $title,
+					'primary'   => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+					'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+					'tertiary'  => $GLOBALS['phpgw_info']['theme']['navbar_bg'],
+					'width'     => '100%',
+					'outerborderwidth' => '0',
+					'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','bg_filler')
+				)
+			);
+	
+			$app_id = $GLOBALS['phpgw']->applications->name2id('expressoMail');
+			$GLOBALS['portal_order'][] = $app_id;
+	
+			$var = Array(
+				'up'       => Array('url' => '/set_box.php', 'app' => $app_id),
+				'down'     => Array('url' => '/set_box.php', 'app' => $app_id),
+				'close'    => Array('url' => '/set_box.php', 'app' => $app_id),
+				'question' => Array('url' => '/set_box.php', 'app' => $app_id),
+				'edit'     => Array('url' => '/set_box.php', 'app' => $app_id)
+			);
+	
+			while(list($key,$value) = each($var))		
+				$portalbox->set_controls($key,$value);
+	
+			$portalbox->data = $data;
+		}			
 		echo "\n".'<!-- BEGIN Mailbox info -->'."\n".$portalbox->draw($extra_data).'<!-- END Mailbox info -->'."\n";
 	}
