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
--- 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
--- 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();
--- rcube_smtp.inc (revision 587) +++ rcube_smtp.inc (working copy) @@ -53,9 +53,9 @@ { global $SMTP_CONN, $CONFIG; $smtp_timeout = null;
$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'])
I like the concept Brett. I would be intrested in this feature also.
-Chris
Brett Patterson wrote:
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
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete this material from any computer.
In accordance with industry regulations, all messages are retained and are subject to monitoring.
This message has been scanned for viruses and dangerous content and is believed to be clean.
Securities offered through Cantella & Co., Inc., Member NASD/SIPC. Home Office: 2 Oliver Street, 11th Floor, Boston, MA 02109 Telephone: (617)521-8630
Hi Brett,
On 6/4/07, Brett Patterson brett@bpatterson.net wrote:
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.
(Excuse me, I only briefly scanned your patch, but ...) Correct me if I am wrong, but how is this different from default behavior?
Cheers, Till
Till:
The default behavior uses one smtp server for all imap servers. This patch will allow you to define what smtp server to use with which imap server. So if you check mail on domain1.com and domain2.org, you can set up smtp servers for each to be used separately.
~Brett
till wrote:
Hi Brett,
On 6/4/07, Brett Patterson brett@bpatterson.net wrote:
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.
(Excuse me, I only briefly scanned your patch, but ...) Correct me if I am wrong, but how is this different from default behavior?
Cheers, Till
On 6/4/07, Brett Patterson brett@bpatterson.net wrote:
Till:
The default behavior uses one smtp server for all imap servers. This patch will allow you to define what smtp server to use with which imap server. So if you check mail on domain1.com and domain2.org, you can set up smtp servers for each to be used separately.
Apologies. ;)
Love your patch. I'll include it in vnext.
Till
Brett,
This is a great idea, for which I've already had use! I did a couple fixes and enhancements to your patch (it now does smtp-server-specific usernames and passwords if desired). Check it out and let me know if it's good. If so, I'll commit it.
On Mon, 04 Jun 2007 07:24:36 -0400, Brett Patterson brett@bpatterson.net wrote:
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
--
Eric Stadtherr
estadtherr@gmail.com
Nice approach! Rather than having all config parameters (smpt_server, smtp_port, smtp_user, smtp_pass) as an array, I suggest to use URLs in $rcmail_config['smtp_server'].
Example: $rcmail_config['smtp_server'] = array( 'imap.host1.tld' => smtp.host1.tld', 'imap.host2.tld' => 'smtp://user:pass@smtp.host2.tld', 'imap.host3.tld' => 'ssl://%u:%p@smtp.host3.tld:465/CRAM-MD5', );
(with 'smtp_auth_type' as folder name)
in rcube_smtp.inc simply use parse_url() to get the host-specific settings, of course with a fallback on the "old" parameters. With this solution we can get rid of four config properties.
Just my 2 cents.
~Thomas
2007/6/14, Eric Stadtherr estadtherr@gmail.com:
Brett,
This is a great idea, for which I've already had use! I did a couple fixes and enhancements to your patch (it now does smtp-server-specific usernames and passwords if desired). Check it out and let me know if it's good. If so, I'll commit it.
I like it. If it works code-wise, then please commit it!!
I just wanted to get the basic functionality in there. Thanks for improving it Eric and Thomas.
~Brett
Thomas Bruederli wrote:
Nice approach! Rather than having all config parameters (smpt_server, smtp_port, smtp_user, smtp_pass) as an array, I suggest to use URLs in $rcmail_config['smtp_server'].
Example: $rcmail_config['smtp_server'] = array( 'imap.host1.tld' => smtp.host1.tld', 'imap.host2.tld' => 'smtp://user:pass@smtp.host2.tld', 'imap.host3.tld' => 'ssl://%u:%p@smtp.host3.tld:465/CRAM-MD5', );
(with 'smtp_auth_type' as folder name)
in rcube_smtp.inc simply use parse_url() to get the host-specific settings, of course with a fallback on the "old" parameters. With this solution we can get rid of four config properties.
Just my 2 cents.
~Thomas
2007/6/14, Eric Stadtherr estadtherr@gmail.com:
Brett,
This is a great idea, for which I've already had use! I did a couple fixes and enhancements to your patch (it now does smtp-server-specific usernames and passwords if desired). Check it out and let me know if it's good. If so, I'll commit it.