Author Topic: patch for multiple smtp servers  (Read 12012 times)

Offline tauu

  • Newbie
  • *
  • Posts: 2
patch for multiple smtp servers
« 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.



Offline evros

  • Newbie
  • *
  • Posts: 5
patch for multiple smtp servers
« Reply #1 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?

Offline sirvanderwaal

  • Newbie
  • *
  • Posts: 2
How to fix your problem
« Reply #2 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

Offline evros

  • Newbie
  • *
  • Posts: 5
patch for multiple smtp servers
« Reply #3 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?

Offline sirvanderwaal

  • Newbie
  • *
  • Posts: 2
patch for multiple smtp servers
« Reply #4 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

Offline evros

  • Newbie
  • *
  • Posts: 5
patch for multiple smtp servers
« Reply #5 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

But it's old - posted in 2007.

Any other ideas, William? I'll also try the code posted in the thread above.

Offline jay

  • Jr. Member
  • **
  • Posts: 10
patch for multiple smtp servers
« Reply #6 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

Offline tom555

  • Jr. Member
  • **
  • Posts: 19
patch for multiple smtp servers
« Reply #7 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.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
patch for multiple smtp servers
« Reply #8 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.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline tom555

  • Jr. Member
  • **
  • Posts: 19
patch for multiple smtp servers
« Reply #9 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.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
patch for multiple smtp servers
« Reply #10 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!
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline tom555

  • Jr. Member
  • **
  • Posts: 19
patch for multiple smtp servers
« Reply #11 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.

Offline tom555

  • Jr. Member
  • **
  • Posts: 19
patch for multiple smtp servers
« Reply #12 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.

Offline glycome8472

  • Newbie
  • *
  • Posts: 2
Verification from the same domain
« Reply #13 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?

Offline glycome8472

  • Newbie
  • *
  • Posts: 2
Roundcube 0.3.1. patch
« Reply #14 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