Roundcube Community Forum

 

Conditional smtp_server English/Spanish

Started by pika503, May 24, 2013, 12:17:10 PM

Previous topic - Next topic

pika503

ENGLISH
Hello everybody.
I want your help with roundcube settings.
I have UBUNTU 12.10LTS x64 server. It also has installed Postfix, fetchmail, Dovecot and Roundcube course.
The problem is that the office has a website dominio.gob.sv with email service.
The email provided is 2GB for all accounts. The server does not support relayhost. But shipments supports SMTP authentication.
I do not want the internal mail has to go to the web server and then return to the internal server.
if I modify the following lines in the file main.in.php:
$ rcmail_config ['smtp_server'] = 'mail.dominio.gob.sv';
$ rcmail_config ['smtp_port'] = 26;
$ rcmail_config ['smtp_user'] = '% u'. '@ dominio.gob.sv';
$ rcmail_config ['smtp_pass'] = '% p';
$ rcmail_config ['smtp_auth_pw'] = '% p';

Send mail to the outside, but the internal mail reaches the web server and then returns to the internal server. Waste of bandwidth that can be distributed locally.

but if I modify the following lines in the file main.in.php:
$ rcmail_config ['smtp_server'] = 'localhost';
$ rcmail_config ['smtp_port'] = 25;
$ rcmail_config ['smtp_user'] ='';
$ rcmail_config ['smtp_pass'] ='';
$ rcmail_config ['smtp_auth_pw'] ='';

send to internal mail but not external.

So I thought to use a condition to choose the smtp server.
Modifying the main.inc.php:
if (! stristr (strtolower ($ mailto), 'dominio.gob.sv')) {
$ rcmail_config ['smtp_server'] = 'localhost';
$ rcmail_config ['smtp_port'] = 25;
$ rcmail_config ['smtp_user'] ='';
$ rcmail_config ['smtp_pass'] ='';
$ rcmail_config ['smtp_auth_pw'] ='';
else {}
$ rcmail_config ['smtp_server'] = 'mail.dominio.gob.sv';
$ rcmail_config ['smtp_port'] = 26;
$ rcmail_config ['smtp_user'] = '% u'. '@ dominio.gob.sv';
$ rcmail_config ['smtp_pass'] = '% p';
$ rcmail_config ['smtp_auth_pw'] = '% p';
}

For sending emails to dominio.gob.sv Use the postfix at localhost.
And when sending emails to one external, use mail.dominio.gob.sv.

The problem is that I do not recognize the condition.
I need your help.
Thank you.
Greetings from El Salvador.

ESPAÑOL
Deseo su ayuda con la configuracion de ROUNDCUBE.
Tengo un servidor UBUNTU 12.10LTS x64. Tambien tiene instalado Postfix, fetchmail, Dovecot y por supuesto Roundcube.
El problema es que la oficina tiene una pagina web dominio.gob.sv, con servicio de correo electronico.
El correo electronico proporcionado es de 2GB para todas las cuentas. El servidor no soporta RELAYHOST. Pero soporta envios SMTP con autenticacion.
No deseo que el correo electronico interno tenga que ir al servidor web para luego regresar al servidor interno.
si modifico las siguientes lineas en el archivo  main.in.php:
$rcmail_config['smtp_server'] = 'mail.dominio.gob.sv';
$rcmail_config['smtp_port'] = 26;
$rcmail_config['smtp_user'] = '%u'.'@dominio.gob.sv';
$rcmail_config['smtp_pass'] = '%p';
$rcmail_config['smtp_auth_pw'] = '%p';

Envia correos al exterior, pero el correo interno llega al servidor web y luego regresa al servidor interno. Desperdicio de ancho de banda porque puede distribuirse de forma local.

pero si modifico las siguientes lineas en el archivo  main.in.php:
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['smtp_port'] = 25;
$rcmail_config['smtp_user'] = '';
$rcmail_config['smtp_pass'] = '';
$rcmail_config['smtp_auth_pw'] = '';

envia al correo interno pero no al externo

Por eso pense en utilizar una condicion para elegir el servidor smtp.
Modificando el main.inc.php:
if(!stristr(strtolower ($mailto), 'dominio.gob.sv')){
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['smtp_port'] = 25;
$rcmail_config['smtp_user'] = '';
$rcmail_config['smtp_pass'] = '';
$rcmail_config['smtp_auth_pw'] = '';
}else{
$rcmail_config['smtp_server'] = 'mail.dominio.gob.sv';
$rcmail_config['smtp_port'] = 26;
$rcmail_config['smtp_user'] = '%u'.'@dominio.gob.sv';
$rcmail_config['smtp_pass'] = '%p';
$rcmail_config['smtp_auth_pw'] = '%p';
}


Para que al enviar correos a dominio.gob.sv utilize el postfix en localhost.
Y cuando envie correos a uno externo, utilize mail.dominio.gob.sv.

El problema es que no me reconoce la condicion.
Necesito de su ayuda.
Gracias.
Saludos desde El Salvador.

Yoni

How about:

$ rcmail_config ['smtp_server'] = 'localhost';
$ rcmail_config ['smtp_port'] = 25;
$ rcmail_config ['smtp_user'] ='%u';
$ rcmail_config ['smtp_pass'] ='%p';
$ rcmail_config ['smtp_auth_pw'] =null;


To define the domain:

// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple hosts
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %d = domain.tld

$rcmail_config['username_domain'] = 'dominio.gob.sv';

pika503

Quote from: Yoni on May 24, 2013, 06:09:12 PM
How about:

$ rcmail_config ['smtp_server'] = 'localhost';
$ rcmail_config ['smtp_port'] = 25;
$ rcmail_config ['smtp_user'] ='%u';
$ rcmail_config ['smtp_pass'] ='%p';
$ rcmail_config ['smtp_auth_pw'] =null;


To define the domain:

// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple hosts
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %d = domain.tld

$rcmail_config['username_domain'] = 'dominio.gob.sv';

Thanks, but that does not solve my problem.
Need to use two configurations, one for local and one for external.
Local --- POSTFIX localhost:25
External-- authentication dominio.gob.sv
:D

Yoni

Edit main.inc.php

$rcmail_config['include_host_config'] = array(
  'localhost' => 'localhost_config.inc.php',
  'dominio.gob.sv' => 'dominio.gob.sv_config.inc.php'
);

localhost_config.inc.php and dominio.gob.sv_config.inc.php should be saved into ./config/ folder. Host-specific configurations will be merged over the main config file. They only need to contain the parameters that differ from the main configuration.

That should do it for what you want.