Devs:

Here's a patch I did last night to allow for multiple SMTP servers to be used with multiple IMAP servers. If you don't specify one, then the default mail function in php is used.

I can't commit, so if someone would be so kind as to double-check my work (I tested on two different SMTP servers and it seems to work) and commit it, I'd appreciate it.

~Brett
Index: main.inc.php.dist
===================================================================
--- main.inc.php.dist   (revision 587)
+++ main.inc.php.dist   (working copy)
@@ -60,9 +60,13 @@
 // use this host for sending mails.
 // to use SSL connection, set ssl://smtp.host.com
 // if left blank, the PHP mail() function is used
+// Specify an array of servers for multi-smtp host support
+// in fashion of host=>smtp_server.
 $rcmail_config['smtp_server'] = '';
 
 // SMTP port (default is 25; 465 for SSL)
+// If using multiple SMTP servers, specify ports in array
+// in fashion of smtp_server=>port
 $rcmail_config['smtp_port'] = 25;
 
 // SMTP username (if required) if you use %u as the username RoundCube
Index: sendmail.inc
===================================================================
--- sendmail.inc        (revision 587)
+++ sendmail.inc        (working copy)
@@ -314,7 +314,7 @@
 if (!$savedraft) {
 
   // send thru SMTP server using custom SMTP library
-  if ($CONFIG['smtp_server'])
+  if ($_SESSION['smtp_server'] != 'phpMail')
     {
     // generate list of recipients
     $a_recipients = array($mailto);
Index: main.inc
===================================================================
--- main.inc    (revision 587)
+++ main.inc    (working copy)
@@ -562,6 +562,26 @@
     $_SESSION['user_lang'] = $sess_user_lang;
     $_SESSION['password']  = encrypt_passwd($pass);
     $_SESSION['login_time'] = mktime();
+               
+               // If multi-SMTP servers, use correct one
+               // Otherwise, use the general SMTP server
+               // or use phpMail function
+               if(is_array($CONFIG['smtp_server']) && 
isset($CONFIG['smtp_server'][$host]))
+                       {
+                       $_SESSION['smtp_server'] = 
$CONFIG['smtp_server'][$host];
+                       }
+               elseif(is_array($CONFIG['smtp_server']) && 
!isset($CONFIG['smtp_server'][$host]))
+                       {
+                       $_SESSION['smtp_server'] = 'phpMail';
+                       }
+               elseif(is_string($CONFIG['smtp_server']) && 
!empty($CONFIG['smtp_server']) && $CONFIG['smtp_server'] != '')
+                       {
+                       $_SESSION['smtp_server'] = $CONFIG['smtp_server'];
+                       }
+               else
+                       {
+                       $_SESSION['smtp_server'] = 'phpMail';
+                       }
 
     // force reloading complete list of subscribed mailboxes
     rcmail_set_imap_prop();
Index: rcube_smtp.inc
===================================================================
--- rcube_smtp.inc      (revision 587)
+++ rcube_smtp.inc      (working copy)
@@ -53,9 +53,9 @@
   {
   global $SMTP_CONN, $CONFIG;
   $smtp_timeout = null;
-  $smtp_host = $CONFIG['smtp_server'];
-  $smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25;
-  $smtp_host_url = parse_url($CONFIG['smtp_server']);
+  $smtp_host = $_SESSION['smtp_server'];
+  $smtp_port = (is_array($CONFIG['smtp_port'][$smtp_host]) && 
isset($CONFIG['smtp_port'][$smtp_host])) ? $CONFIG['smtp_port'][$smtp_host] : 
25;
+  $smtp_host_url = parse_url($smtp_host);
   
   // overwrite port
   if ($smtp_host_url['host'] && $smtp_host_url['port'])

Reply via email to