Index: trunk/expressoMail1_2/controller.php
===================================================================
--- trunk/expressoMail1_2/controller.php	(revision 2)
+++ trunk/expressoMail1_2/controller.php	(revision 504)
@@ -20,5 +20,5 @@
 	// NO ACTION
 	else
-		return $_SESSION['response'] = 'false';
+		return $_SESSION['response'] = 'Post-Content-Length';
 	
 	// Load dinamically class file.
Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 485)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 504)
@@ -42,8 +42,24 @@
 	{
 		$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' => imap_last_error())));
+	 	$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()))));
 		return $this->mbox;
 	 }
 
+	function parse_error($error){
+		// This error is returned from Imap.
+		if(strstr($error,'Connection refused')) {
+			return str_replace("%1", $this->functions->getLang("Mail"), $this->functions->getLang("Connection failed with %1 Server. Try later."));
+		}
+		// This error is returned from Postfix.
+		elseif(strstr($error,'message file too big')) {
+			return str_replace("%1", ini_get('upload_max_filesize'),$this->functions->getLang('The size of this message has exceeded  the limit (%1B).'));			
+		}
+		// This condition verifies if SESSION is expired.
+		elseif(!count($_SESSION))			
+			return "nosession";
+
+		return $error;
+	}
+	
 	function get_range_msgs2($params)
 	{
@@ -833,6 +849,6 @@
 		}
 
-		//$mbox_stream = $this->open_mbox($folder);
-	 	$mbox_stream = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => imap_last_error())));
+		//$mbox_stream = $this->open_mbox($folder);	 	
+	 	$mbox_stream = @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()))));
 		
 		foreach ($msgs_number as $msg_number)
@@ -1259,5 +1275,5 @@
 			}
 			if( $total_uploaded_size > $upload_max_filesize)
-				return 'false';			
+				return $this->parse_error("message file too big");			
 		}			
 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1292,8 +1308,10 @@
 			$mail->ConfirmReadingTo = $_SESSION['phpgw_info']['expressomail']['user']['email'];
 ////////////////////////////////////////////////////////////////////////////////////////////////////
+
 		$sent = $mail->Send();
+		
 		if(!$sent)
 		{
-   			return $mail->ErrorInfo;
+   			return $this->parse_error($mail->ErrorInfo);
 		}
 		else
@@ -1536,5 +1554,5 @@
 				$userID 	= $_SESSION['phpgw_info']['expressomail']['user']['userid'];								
 				$server 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
-				$mbox		= @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}INBOX", $accountID, $pass) or die(serialize(array('imap_error' => imap_last_error())));
+				$mbox		= @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}INBOX", $accountID, $pass) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error()))));
 				if(!$mbox)
 					return imap_last_error();
Index: trunk/expressoMail1_2/inc/class.phpmailer.php
===================================================================
--- trunk/expressoMail1_2/inc/class.phpmailer.php	(revision 426)
+++ trunk/expressoMail1_2/inc/class.phpmailer.php	(revision 504)
@@ -345,4 +345,6 @@
      */
     function Send() {
+    	
+    
         $header = "";
         $body = "";
@@ -351,8 +353,8 @@
         if(((count($this->to) + count($this->cc) + count($this->bcc)) < 1) && (!$this->SaveMessageAsDraft))
         {
-            $this->SetError($this->Lang("provide_address"));
+            $this->SetError($this->Lang("provide_address"));            
             return false;
         }
-
+		
         // Set whether the message is multipart/alternative
         if(!empty($this->AltBody))
@@ -379,5 +381,5 @@
                 break;
             default:
-            $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
+	            $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
                 $result = false;
                 break;
@@ -1168,5 +1170,5 @@
           case "base64":
               // chunk_split is found in PHP >= 3.0.6
-              $encoded = chunk_split(base64_encode($str), 76, $this->LE);
+              $encoded = @chunk_split(base64_encode($str), 76, $this->LE);
               break;
           case "7bit":
Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 485)
+++ trunk/expressoMail1_2/js/main.js	(revision 504)
@@ -77,5 +77,5 @@
 
 
-function show_msg(msg_info){
+function show_msg(msg_info){	
 	if(!verify_session(msg_info))
 		return;
@@ -872,10 +872,10 @@
 	}
 	else{			
-		if(data == 'false')
+		if(data == 'Post-Content-Length')
 			write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',Element('upload_max_filesize').value));
-		else if(data == null)
-			write_msg(get_lang("your session could not be verified."));
+		else if(data)
+			write_msg(data);
 		else
-			write_msg(data);
+			write_msg(get_lang("Connection failed with %1 Server. Try later.", "Web"));
 	}
 }
@@ -1366,9 +1366,13 @@
 
 function verify_session(data){
+
 	if(data && data.imap_error) {
-		write_msg(get_lang("your session could not be verified."));
-		// Hold session for edit message.
-		if(!hold_session)
-			location.href="../login.php?cd=10&phpgw_forward=%2FexpressoMail1_2%2Findex.php";
+		if(data.imap_error == "nosession")
+			write_msg(get_lang("your session could not be verified."));
+		else
+			write_msg(data.imap_error);
+		// Hold sesion for edit message.
+		//if(!hold_session)
+		//	location.href="../login.php?cd=10&phpgw_forward=%2FexpressoMail1_2%2Findex.php";		
 		return false;
 	}
