Ignore:
Timestamp:
10/07/08 14:50:11 (16 years ago)
Author:
niltonneto
Message:

Vide no Trac #344 - Melhorar tratamento de erros (parte 1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r485 r504  
    4242        { 
    4343                $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 
    44                 $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()))); 
     44                $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())))); 
    4545                return $this->mbox; 
    4646         } 
    4747 
     48        function parse_error($error){ 
     49                // This error is returned from Imap. 
     50                if(strstr($error,'Connection refused')) { 
     51                        return str_replace("%1", $this->functions->getLang("Mail"), $this->functions->getLang("Connection failed with %1 Server. Try later.")); 
     52                } 
     53                // This error is returned from Postfix. 
     54                elseif(strstr($error,'message file too big')) { 
     55                        return str_replace("%1", ini_get('upload_max_filesize'),$this->functions->getLang('The size of this message has exceeded  the limit (%1B).'));                   
     56                } 
     57                // This condition verifies if SESSION is expired. 
     58                elseif(!count($_SESSION))                        
     59                        return "nosession"; 
     60 
     61                return $error; 
     62        } 
     63         
    4864        function get_range_msgs2($params) 
    4965        { 
     
    833849                } 
    834850 
    835                 //$mbox_stream = $this->open_mbox($folder); 
    836                 $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()))); 
     851                //$mbox_stream = $this->open_mbox($folder);              
     852                $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())))); 
    837853                 
    838854                foreach ($msgs_number as $msg_number) 
     
    12591275                        } 
    12601276                        if( $total_uploaded_size > $upload_max_filesize) 
    1261                                 return 'false';                  
     1277                                return $this->parse_error("message file too big");                       
    12621278                }                        
    12631279//////////////////////////////////////////////////////////////////////////////////////////////////// 
     
    12921308                        $mail->ConfirmReadingTo = $_SESSION['phpgw_info']['expressomail']['user']['email']; 
    12931309//////////////////////////////////////////////////////////////////////////////////////////////////// 
     1310 
    12941311                $sent = $mail->Send(); 
     1312                 
    12951313                if(!$sent) 
    12961314                { 
    1297                         return $mail->ErrorInfo; 
     1315                        return $this->parse_error($mail->ErrorInfo); 
    12981316                } 
    12991317                else 
     
    15361554                                $userID         = $_SESSION['phpgw_info']['expressomail']['user']['userid'];                                                             
    15371555                                $server         = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 
    1538                                 $mbox           = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}INBOX", $accountID, $pass) or die(serialize(array('imap_error' => imap_last_error()))); 
     1556                                $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())))); 
    15391557                                if(!$mbox) 
    15401558                                        return imap_last_error(); 
Note: See TracChangeset for help on using the changeset viewer.