[Vtigercrm-commits] [vtiger-commits] r9816 - in /vtigercrm/branches/5.0.3: index.php modules/Webmails/ListView.php modules/Webmails/MailBox.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Nov 13 03:36:34 EST 2006


Author: richie
Date: Mon Nov 13 01:36:28 2006
New Revision: 9816

Log:
* Fixed some issues with connection string and Full Email View page error - Mickie

Modified:
    vtigercrm/branches/5.0.3/index.php
    vtigercrm/branches/5.0.3/modules/Webmails/ListView.php
    vtigercrm/branches/5.0.3/modules/Webmails/MailBox.php

Modified: vtigercrm/branches/5.0.3/index.php
==============================================================================
--- vtigercrm/branches/5.0.3/index.php (original)
+++ vtigercrm/branches/5.0.3/index.php Mon Nov 13 01:36:28 2006
@@ -438,6 +438,9 @@
 			require_once("modules/$currentModule/Activity.php");
 			$focus = new Activity();
 			break;
+		case 'Webmails':
+			//No need to create a webmail object here
+			break;
 		default:
 			require_once("modules/$currentModule/$currentModule.php");
 			$focus = new $currentModule();

Modified: vtigercrm/branches/5.0.3/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/ListView.php (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/ListView.php Mon Nov 13 01:36:28 2006
@@ -177,6 +177,8 @@
 $numEmails = $elist["count"];
 $headers = $elist["headers"];
 
+$mails_per_page = $MailBox->mails_per_page;
+
 if($start == 1 || $start == "") {
 	$start_message=$numEmails;
 } else {

Modified: vtigercrm/branches/5.0.3/modules/Webmails/MailBox.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/MailBox.php (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/MailBox.php Mon Nov 13 01:36:28 2006
@@ -56,12 +56,12 @@
 		$this->mail_protocol=$this->boxinfo["mail_protocol"]; 
 		$this->ssltype=$this->boxinfo["ssltype"]; 
 		$this->sslmeth=$this->boxinfo["sslmeth"]; 
+
 		$this->box_refresh=trim($this->boxinfo["box_refresh"]);
-		$this->mails_per_page=trim($this->boxinf["mails_per_page"]);
+		$this->mails_per_page=trim($this->boxinfo["mails_per_page"]);
 		if($this->mails_per_page < 1)
         		$this->mails_per_page=20;
 
-		$this->mail_protocol=$this->boxinfo["mail_protocol"];
 		$this->account_name=$this->boxinfo["account_name"];
 		$this->display_name=$this->boxinfo["display_name"];
 		//$this->imapServerAddress=$this->boxinfo["mail_servername"];
@@ -105,46 +105,73 @@
 
 		if($this->mail_protocol == "pop3")
 			$port = "110";
-		else {
-	    		if($mods["imap"]["SSL Support"] == "enabled" && $this->ssltype == "ssl")
+		else
+		{
+	    		if($mods["imap"]["SSL Support"] == "enabled" && $this->ssltype == "tls")
 				$port = "993";
 			else
 				$port = "143";
 		}
 
 		$this->db->println("Building connection string");
-                if(preg_match("/@/",$this->login_username)) {
+                if(preg_match("/@/",$this->login_username)) 
+		{
                         $mailparts = split("@",$this->login_username);
                         $user="".trim($mailparts[0])."";
                         $domain="".trim($mailparts[1])."";
 
 			// This section added to fix a bug when connecting as user at domain.com
-			if($this->readonly == "true") {
-	    			if($mods["imap"]["SSL Support"] == "enabled")
-                                	$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}/readonly}".$this->mailbox;
+			if($this->readonly == "true") 
+			{
+	    			if($mods["imap"]["SSL Support"] == "enabled")
+                                	$connectString = "/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}/readonly";
 				else
-                                	$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/notls/novalidate-cert/user={$user}@{$domain}/readonly}".$this->mailbox;
-			} else {
-	    			if($mods["imap"]["SSL Support"] == "enabled")
-                                	$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}}".$this->mailbox;
+                                	$connectString = "/notls/novalidate-cert/user={$user}@{$domain}/readonly";
+			}
+			else
+			{
+	    			if($mods["imap"]["SSL Support"] == "enabled")
+                                	$connectString = "/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}";
 				else
-                                	$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/notls/novalidate-cert/user={$user}@{$domain}}".$this->mailbox;
-			}
-                } else {
-			if($this->readonly == "true") {
-	    			if($mods["imap"]["SSL Support"] == "enabled")
-					$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/".$this->ssltype."/".$this->sslmeth."/readonly}".$this->mailbox;
+                                	$connectString = "/notls/novalidate-cert/user={$user}@{$domain}";
+			}
+		}
+		else
+		{
+			if($this->readonly == "true")
+			{
+	    			if($mods["imap"]["SSL Support"] == "enabled")
+					$connectString = "/".$this->ssltype."/".$this->sslmeth."/readonly";
 	    			else
-					$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/notls/novalidate-cert/readonly}".$this->mailbox;
-			} else {
-	    			if($mods["imap"]["SSL Support"] == "enabled")
-					$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/".$this->ssltype."/".$this->sslmeth."}".$this->mailbox;
+					$connectString = "/notls/novalidate-cert/readonly";
+			}
+			else
+			{
+	    			if($mods["imap"]["SSL Support"] == "enabled")
+					$connectString = "/".$this->ssltype."/".$this->sslmeth;
 	    			else
-					$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/notls/novalidate-cert}".$this->mailbox;
-			}
-		}
+					$connectString = "/notls/novalidate-cert";
+			}
+		}
+
+		$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port.$connectString."}".$this->mailbox;
+		//Reference - http://forums.vtiger.com/viewtopic.php?p=33478#33478 - which has no tls or validate-cert
+		$connectString1 = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."}".$this->mailbox; 
+
 		$this->db->println("Done Building Connection String.. Connecting to box");
-		$this->mbox = imap_open($connectString, $this->login_username, $this->secretkey); 
+
+		if(!$this->mbox = @imap_open($connectString, $this->login_username, $this->secretkey))
+		{
+			//try second string which has no tls or validate-cert
+			if(!$this->mbox = @imap_open($connectString1, $this->login_username, $this->secretkey))
+			{
+				global $current_user;
+				$this->db->println("CONNECTION ERROR - Could not be connected to the server using imap_open function through the connection strings $connectString and $connectString1");
+				echo "<br>&nbsp;<b>Could not connect to the server. Please check the server details <a href='index.php?module=Settings&action=AddMailAccount&record=".$current_user->id."'> Here </a></b>";
+				exit;
+			}
+		}
+
 		$this->db->println("Done connecting to box");
 	}
 } // END CLASS





More information about the vtigercrm-commits mailing list