Roundcube Community Forum

Release Support => Release Discussion => Topic started by: tauu on January 18, 2009, 12:19:56 PM

Title: patch for multiple smtp servers
Post by: tauu on January 18, 2009, 12:19:56 PM
hi everybody,

I changed the 0.2-stable release to allow multiple smtp servers instead of just one.

The servers are configured int main.inc.php analog to following exmaple:
Code: [Select]

$rcmail_config['smtp'] = array( 'default' => array( 'smtp_server' => 'localhost',
                                                    'smtp_port'   => 25,
                                                    'smtp_user'   => '%u',
                                                    'smtp_pass'   => '%p',
                                                    'smtp_auth_type' => '',
                                                    'smtp_helo_host' => ''),
                                'gmail.com' => array( 'smtp_server' => 'smtp.googlemail.com',
                                                    'smtp_port'   => 25,
                                                    'smtp_user'   => '%u',
                                                    'smtp_pass'   => '%p',
                                                    'smtp_auth_type' => '',
                                                    'smtp_helo_host' => '')
                                 );


Which server should be used to send an email is determined by extracting the domain of the "from" address  and then selecting the corresponding element in the array $rcmail_config['smtp']. If the element does not exsits, the default configuration is used instead.

The only file that needed to be changed is rcube_smtp.inc. The modified version and  a diff is attached to this post.


Title: patch for multiple smtp servers
Post by: evros on January 21, 2009, 07:21:00 AM
Thank you tauu for this patch!

But I'm afraid it doesn't work. I think I did something wrong, but I don't know what :(


What I did
========
I replaced the original "rcube_smtp.inc" with the one you attached to your post. I haven't changed anything until now. Maybe that's the reason it doesn't work? But I don't know what to change.

Here's the part of the smtp configuration of my main.inc.php

Code: [Select]


// SMTP Test

$rcmail_config['smtp'] = array(
'googlemail.com' => array(
'smtp_server' => 'ssl://smtp.googlemail.com',
'smtp_port'   => 587,
'smtp_user'   => '%u',
'smtp_pass'   => '%p',
'smtp_auth_type' => '',
'smtp_helo_host' => ''),
'koeln.de' => array(
'smtp_server' => 'mail.koeln.de',
'smtp_port'   => 25,
'smtp_user'   => '%u',
'smtp_pass'   => '%p',
'smtp_auth_type' => '',
'smtp_helo_host' => ''),
'default' => array(
'smtp_server' => 'localhost',
'smtp_port'   => 25,
'smtp_user'   => '%u',
'smtp_pass'   => '%p',
'smtp_auth_type' => '',
'smtp_helo_host' => '')
);

// SMTP Test



Do you have an idea where the fault is?
Title: How to fix your problem
Post by: sirvanderwaal on February 05, 2009, 03:03:24 PM
I installed this patch and it works great... %u and %p won't work for passing the username and password though. You have to actually type those values in for each server, and if any of them are wrong in the array none of them in the array will work.

-William
Title: patch for multiple smtp servers
Post by: evros on February 12, 2009, 08:52:40 AM
I'm afraid your advice didn't help. But the login data is definitely correct. I still cannot send any mails via roundcube :( Any other ideas?
Title: patch for multiple smtp servers
Post by: sirvanderwaal on April 07, 2009, 09:27:04 AM
sorry for not getting back to you earlier... %u and %p are stand-ins for the actual username and the actual password. Try replacing those with the actual username and password and be aware that some mail servers don't like just the name of the email they like the whole email address, e.g.: william@gmail.com instead of just "william" for the username.

Let me know how that works for you...

-William
Title: patch for multiple smtp servers
Post by: evros on April 16, 2009, 08:44:31 AM
Hi William,

I've already tried that, but it doesn't work :(


Code: [Select]
$rcmail_config['smtp'] = array(
'googlemail.com' => array(
'smtp_server' => 'ssl://smtp.googlemail.com',
'smtp_port'   => 465,
'smtp_user'   => 'username@domain.de',
'smtp_pass'   => 'password',
'smtp_auth_type' => '',
'smtp_helo_host' => ''),
'koeln.de' => array(
'smtp_server' => 'mail.koeln.de',
'smtp_port'   => 25,
'smtp_user'   => 'username@domain.de',
'smtp_pass'   => 'password',
'smtp_auth_type' => '',
'smtp_helo_host' => ''),
'default' => array(
'smtp_server' => 'localhost',
'smtp_port'   => 25,
'smtp_user'   => '%u',
'smtp_pass'   => '%p',
'smtp_auth_type' => '',
'smtp_helo_host' => '')
);



I found another thread for this feature -> RoundCube Mailing Lists (http://lists.roundcube.net/mail-archive/dev/2007-06/0000023.html)

But it's old - posted in 2007.

Any other ideas, William? I'll also try the code posted in the thread above.
Title: patch for multiple smtp servers
Post by: jay on July 13, 2009, 05:22:11 PM
is this working with rc0.2.1? because I can't bring it to work!

I replace the rc_smtp.inc file and change the config. I can send emails but I don't think by the right smtp-server.

In the code of rc_smtp.inc there are a lot of response[] command with some information. where can I read this (don't show up in console or in log-file)?

thanks for any help
jay
Title: patch for multiple smtp servers
Post by: tom555 on September 13, 2009, 02:20:25 PM
Is this patch working with roundcube 0.3 stable too ? Its the only thing i hardly miss. Sending mails via one smtp server is not ver good if you use the plugin for external imap accounts.
Title: patch for multiple smtp servers
Post by: rosali on September 13, 2009, 03:02:24 PM
Why not ... it was intended to restrict smtp access for remote accounts. IMO, the admin should have control what users are sending out. I would never open this backdoor.
Title: patch for multiple smtp servers
Post by: tom555 on September 13, 2009, 03:54:10 PM
The problem is, that this patch is for the file "rcube_smtp.inc". This file is no longer present in roundcube 0.3 stable. And so i thought that the smtp backend was changed.

Sure it is abig security hole, when you open roundcube for the public or a lot of users, but in my case, only i and my wife use it for emails and it is secured with an extra htaccess password before.

I think the external imap accounts plugin doesn't make any sense, when you are not able to use more smtp servers.
Title: patch for multiple smtp servers
Post by: rosali on September 13, 2009, 04:16:12 PM
Why don't you use your own smtp service? I do not see any reason to allow users to use third party smtp's. Define your own smtp user in main.inc.php!
Title: patch for multiple smtp servers
Post by: tom555 on September 13, 2009, 04:51:40 PM
My Problem is, that i use gmail and additionally i use my mail service o my webspace. Some recipients don't accept mails, when i for example send a mail from "xxxx@googlemail.com" via smtp "xxxxx@myspace.com". That is the reason. Some mail servers check if the sender is available on the smtp server and don't accept the mail, if not.
Title: patch for multiple smtp servers
Post by: tom555 on September 13, 2009, 05:29:51 PM
@rosali
now i got it. It was possible to configure my smtp, to let others through as well. It works now perfect with only one smtp server.
Title: Verification from the same domain
Post by: glycome8472 on November 18, 2009, 02:58:09 AM
People keep on saying that it's not necessary to configure multiple SMTP accounts; stating that you should configure your own SMTP server.

I must be missing something; some email servers require that you are authenticated with them to send emails internally (i.e. same domain name as your sending account).  

How can this be accomplished with postfix for example?
Title: Roundcube 0.3.1. patch
Post by: glycome8472 on November 18, 2009, 05:55:47 AM
I have posted a patched version of RoundCube at the URL below; which allows for mutliple SMTP servers on the same setup.  I've never written any PHP before so be careful.

roundcubemail-0.3.1_multismtp - Roundcube with multiple SMTP support (http://nixbioinf.org/cgit/cgit.cgi/roundcubemail-0.3.1_multismtp/)
Title: patch of the patch to enable different Sent folders for different mail domains
Post by: SK-Sly on April 07, 2010, 04:41:21 PM
To allow storage of sent items in special sent folders for configured mail domains I patched the source.

File: program/steps/mail/sendmail.inc
search for the line "// Determine which folder to save message" and change the source:

// Determine which folder to save message
if ($savedraft)
  $store_target = $CONFIG['drafts_mbox'];
else {
  // begin: skr patch
  $sent_box = $CONFIG['sent_mbox'];
  $RCMAIL = rcmail::get_instance();
  list($dummy,$domain) = split("@",$from);
  $smtpConfig=$RCMAIL->config->getSmtpConfig($domain);
  $special_box = $smtpConfig['smtp_sent_mbox'];
  if($special_box != "") {
    $sent_box = $special_box;
  }
  $store_target = $sent_box;
  // end: skr patch
}

if ($store_target)
...

to configure this feature add the entry "smtp_sent_mbox'" to the mail domain specific smtp config:

$rcmail_config['smtp'] = array( 'domain1.de' => array( 'smtp_server' => 'smtp.domain1.de',
  'smtp_port' => 25,
  'smtp_user' => 'user',
  'smtp_pass' => 'password',
  'smtp_auth_type' => '',
  'smtp_helo_host' => '',
  'smtp_log' => TRUE,
  'smtp_debug' => TRUE,
  'smtp_sent_mbox' => ''),
'domain2.de' => array( 'smtp_server' => 'smtp.domain2.de',
  'smtp_port' => 25,
  'smtp_user' => 'user',
  'smtp_pass' => 'password',
  'smtp_auth_type' => '',
  'smtp_helo_host' => '',
  'smtp_log' => TRUE,
  'smtp_debug' => TRUE,
  'smtp_sent_mbox' => 'Sent_domain2'),
'default' => array( 'smtp_server' => 'default.smtp.de',
  'smtp_port' => 25,
  'smtp_user' => 'user',
  'smtp_pass' => 'password',
  'smtp_auth_type' => '',
  'smtp_helo_host' => '',
  'smtp_log' => TRUE,
  'smtp_debug' => TRUE,
  'smtp_sent_mbox' => '')
);

if no mail domain specific sent mbox is configured, the defautt configuration "sent_mbox" will be taken.

have fun!
Sly

PS: I think the better way would be to install an own smtp server...
Title: patch for multiple smtp servers
Post by: bagstone on June 21, 2010, 05:51:21 PM
Quote from: glycome8472;23173
I have posted a patched version of RoundCube at the URL below; which allows for mutliple SMTP servers on the same setup.  I've never written any PHP before so be careful.

roundcubemail-0.3.1_multismtp - Roundcube with multiple SMTP support (http://nixbioinf.org/cgit/cgit.cgi/roundcubemail-0.3.1_multismtp/)


Does anyone still have this file? It's not available anymore.
I'm using RoundCube 0.3.1 and I'm searching desperately for this feature. If someone has this patch for 0.4.0, it would be nice, too, but I don't want to switch back to 0.2.x where multiple SMTP accounts were still supported.