Bugfix by "Chiu Wai Pun" <pun@alumni.ust.hk>
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 3 Jun 2002 07:33:10 +0000 (07:33 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 3 Jun 2002 07:33:10 +0000 (07:33 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2922 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/mail_fetch/README
plugins/mail_fetch/fetch.php
plugins/mail_fetch/options.php

index 239f9fc..b49219f 100644 (file)
@@ -138,6 +138,8 @@ and then add it again.
 ChangeLog
 =========
 
+1.3.1 Bugfix "Chiu Wai Pun" <pun@alumni.ust.hk> 
+
 ---------------------------------------------------------------------------
                    Philippe Mingo <mingo@rotedic.com>
 ---------------------------------------------------------------------------
@@ -178,4 +180,4 @@ ChangeLog
 ----------------------------------------------------------------------------      
 0.2   Now saves account information
 0.1   Initial release by Tyler Akins
-----------------------------------------------------------------------------
\ No newline at end of file
+----------------------------------------------------------------------------
index cb2a7f6..eb00fff 100644 (file)
         //   register_shutdown_function($pop3->quit());
         
         $msglist = $pop3->uidl();
-        
+
         $i = 1;
         for ($j = 1; $j < sizeof($msglist); $j++) {
            if ($msglist["$j"] == $mailfetch_uidl) {
             $Message = "";
             $MessArray = $pop3->get($i);
             
-            if ( (!$MessArray) or (gettype($MessArray) != "array")) {
-                  Mail_Fetch_Status(_("Oops, ") . $pop3->ERROR);
-                  continue 2;
-            }
+            while ( (!$MessArray) or (gettype($MessArray) != "array")) {
+                 Mail_Fetch_Status(_("Oops, ") . $pop3->ERROR);
+                 // re-connect pop3
+                 Mail_Fetch_Status(_("Server error...Disconnect"));
+                $pop3->quit();
+                 Mail_Fetch_Status(_("Re-connect from dead connectoin"));
+                 if (!$pop3->connect($mailfetch_server)) {
+                     Mail_Fetch_Status(_("Oops, ") . $pop3->ERROR );
+                     Mail_Fetch_Status(_("Saving UIDL"));
+                     setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $mailfetch_uidl[$i-1]);
+
+                     continue;
+                 }
+                 $Count = $pop3->login($mailfetch_user, $mailfetch_pass);
+                 if (($Count == false || $Count == -1) && $pop3->ERROR != '') {
+                     Mail_Fetch_Status(_("Login Failed:") . ' ' . $pop3->ERROR );
+                     Mail_Fetch_Status(_("Saving UIDL"));
+                     setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $mailfetch_uidl[$i-1]);
+
+                     continue;
+                 }
+                 Mail_Fetch_Status(_("Re-fetching message ") . "$i" );
+                $MessArray = $pop3->get($i);
+
+            } // end while
             
             while (list($lineNum, $line) = each ($MessArray)) {
                  $Message .= $line;
             if (substr($Line, 0, 1) == '+') {
                 fputs($imap_stream, $Message);
                 sqimap_read_data($imap_stream, "A3$i", false, $response, $message);
-                Mail_Fetch_Status(_("Message appended to mailbox"));
+                if ( $response <> 'OK' ) {
+                    Mail_Fetch_Status(_("Error Appending Message!")." ".$message );
+                    Mail_Fetch_Status(_("Closing POP"));
+                    $pop3->quit();
+                    Mail_Fetch_Status(_("Logging out from IMAP"));
+                    sqimap_logout($imap_stream);
+
+                    Mail_Fetch_Status(_("Saving UIDL"));
+                    setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $mailfetch_uidl[$i-1]);
+                   exit;
+                } else {
+                    Mail_Fetch_Status(_("Message appended to mailbox"));
+                }
                 
                 if ($mailfetch_lmos != 'on') {
                    if( $pop3->delete($i) ) {
             } else {
                 echo "$Line";
                 Mail_Fetch_Status(_("Error Appending Message!"));
+                Mail_Fetch_Status(_("Closing POP"));
+                $pop3->quit();
+                Mail_Fetch_Status(_("Logging out from IMAP"));
+                sqimap_logout($imap_stream);
+
+                // not gurantee corect!
+                Mail_Fetch_Status(_("Saving UIDL"));
+                setPref($data_dir,$username,"mailfetch_uidl_$i_loop", $mailfetch_uidl[$i-1]);
+                exit;
             }
         }
         
index 6bd8ce8..93937ec 100644 (file)
             $mailfetch_server_number--;
             for ($i=$mf_sn;$i<$mailfetch_server_number;$i++) {
                 $tmp=$i+1;
-                setPref($data_dir,$username,"mailfetch_server_$mf_sn", getPref($data_dir, $username, "mailfetch_server_$tmp"));
-                setPref($data_dir,$username,"mailfetch_alias_$mf_sn", getPref($data_dir, $username, "mailfetch_alias_$tmp"));
-                setPref($data_dir,$username,"mailfetch_user_$mf_sn", getPref($data_dir, $username, "mailfetch_user_$tmp"));
-                setPref($data_dir,$username,"mailfetch_pass_$mf_sn",(isset($mf_pass)?encrypt( $mf_pass ) :""));
+                setPref($data_dir,$username,"mailfetch_server_$i", getPref($data_dir, $username, "mailfetch_server_$tmp"));
+                setPref($data_dir,$username,"mailfetch_alias_$i", getPref($data_dir, $username, "mailfetch_alias_$tmp"));
+                setPref($data_dir,$username,"mailfetch_user_$i", getPref($data_dir, $username, "mailfetch_user_$tmp"));
+                setPref($data_dir,$username,"mailfetch_pass_$i",(isset($mf_pass)?encrypt( $mf_pass ) :""));
                 // if( $mf_cypher <> 'on' ) setPref($data_dir,$username,"mailfetch_cypher", 'on');
-                setPref($data_dir,$username,"mailfetch_lmos_$mf_sn", getPref($data_dir, $username, "mailfetch_lmos_$tmp"));
-                setPref($data_dir,$username,"mailfetch_login_$mf_sn", getPref($data_dir, $username, "mailfetch_login_$tmp"));
-                setPref($data_dir,$username,"mailfetch_fref_$mf_sn", getPref($data_dir, $username, "mailfetch_fref_$tmp"));
-                setPref($data_dir,$username,"mailfetch_subfolder_$mf_sn", getPref($data_dir, $username, "mailfetch_subfolder_$tmp"));
+                setPref($data_dir,$username,"mailfetch_lmos_$i", getPref($data_dir, $username, "mailfetch_lmos_$tmp"));
+                setPref($data_dir,$username,"mailfetch_login_$i", getPref($data_dir, $username, "mailfetch_login_$tmp"));
+                setPref($data_dir,$username,"mailfetch_fref_$i", getPref($data_dir, $username, "mailfetch_fref_$tmp"));
+                setPref($data_dir,$username,"mailfetch_subfolder_$i", getPref($data_dir, $username, "mailfetch_subfolder_$tmp"));
             }
             setPref($data_dir,$username,"mailfetch_server_number", $mailfetch_server_number);
         }