From 09e47788e94cc1dee1b8deec4dc7c6435f50b9eb Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Mon, 3 Jun 2002 07:33:10 +0000 Subject: [PATCH] Bugfix by "Chiu Wai Pun" git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2922 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/mail_fetch/README | 4 ++- plugins/mail_fetch/fetch.php | 54 ++++++++++++++++++++++++++++++---- plugins/mail_fetch/options.php | 16 +++++----- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/plugins/mail_fetch/README b/plugins/mail_fetch/README index 239f9fc8..b49219f2 100644 --- a/plugins/mail_fetch/README +++ b/plugins/mail_fetch/README @@ -138,6 +138,8 @@ and then add it again. ChangeLog ========= +1.3.1 Bugfix "Chiu Wai Pun" + --------------------------------------------------------------------------- Philippe Mingo --------------------------------------------------------------------------- @@ -178,4 +180,4 @@ ChangeLog ---------------------------------------------------------------------------- 0.2 Now saves account information 0.1 Initial release by Tyler Akins ----------------------------------------------------------------------------- \ No newline at end of file +---------------------------------------------------------------------------- diff --git a/plugins/mail_fetch/fetch.php b/plugins/mail_fetch/fetch.php index cb2a7f67..eb00fff5 100644 --- a/plugins/mail_fetch/fetch.php +++ b/plugins/mail_fetch/fetch.php @@ -138,7 +138,7 @@ // register_shutdown_function($pop3->quit()); $msglist = $pop3->uidl(); - + $i = 1; for ($j = 1; $j < sizeof($msglist); $j++) { if ($msglist["$j"] == $mailfetch_uidl) { @@ -180,10 +180,31 @@ $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; @@ -198,7 +219,19 @@ 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) ) { @@ -210,6 +243,15 @@ } 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; } } diff --git a/plugins/mail_fetch/options.php b/plugins/mail_fetch/options.php index 6bd8ce84..93937ec0 100644 --- a/plugins/mail_fetch/options.php +++ b/plugins/mail_fetch/options.php @@ -66,15 +66,15 @@ $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); } -- 2.25.1