BUG 14723 "Error en la configuracióe un correo..." SOLVED

- Error en la configuracióe un correo SMTP.
- Problema resuelto, en ADMIN > Email se agrega un nuevo campo "From Mail" en dynaform "Configuration", el cual permite
  introducir el mail del usuario. para el presente bug es necesario llenar este campo cuando se haga el test se realizara
  correctamente.
This commit is contained in:
Luis Fernando Saisa Lopez
2014-04-28 17:02:38 -04:00
parent ec0c7731b6
commit 3cf5e5caa9
3 changed files with 85 additions and 32 deletions

View File

@@ -251,9 +251,13 @@ class spoolRun
*/ */
private function handleFrom () private function handleFrom ()
{ {
$eregA = "/^.*@.*$/";
if (strpos( $this->fileData['from'], '<' ) !== false) { if (strpos( $this->fileData['from'], '<' ) !== false) {
//to validate complex email address i.e. Erik A. O <erik@colosa.com> //to validate complex email address i.e. Erik A. O <erik@colosa.com>
preg_match( $this->longMailEreg, $this->fileData['from'], $matches ); $ereg = (preg_match($eregA, $this->fileData["from"]))? $this->longMailEreg : "/^(.*)(<(.*)>)$/";
preg_match($ereg, $this->fileData["from"], $matches);
if (isset( $matches[1] ) && $matches[1] != '') { if (isset( $matches[1] ) && $matches[1] != '') {
//drop the " characters if they exist //drop the " characters if they exist
$this->fileData['from_name'] = trim( str_replace( '"', '', $matches[1] ) ); $this->fileData['from_name'] = trim( str_replace( '"', '', $matches[1] ) );
@@ -269,7 +273,8 @@ class spoolRun
$this->fileData['from_email'] = trim( $matches[3] ); $this->fileData['from_email'] = trim( $matches[3] );
} else { } else {
//to validate simple email address i.e. erik@colosa.com //to validate simple email address i.e. erik@colosa.com
preg_match( $this->mailEreg, $this->fileData['from'], $matches ); $ereg = (preg_match($eregA, $this->fileData["from"]))? $this->mailEreg : "/^(.*)$/";
preg_match($ereg, $this->fileData["from"], $matches);
if (! isset( $matches[0] )) { if (! isset( $matches[0] )) {
throw new Exception( 'Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING'] ); throw new Exception( 'Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING'] );

View File

@@ -403,6 +403,7 @@ class adminProxy extends HttpProxyController
$server = $_POST['server']; $server = $_POST['server'];
$user = $_POST['user']; $user = $_POST['user'];
$passwd = $_POST['passwd']; $passwd = $_POST['passwd'];
$fromMail = $_POST["fromMail"];
$passwdHide = $_POST['passwdHide']; $passwdHide = $_POST['passwdHide'];
if (trim($passwdHide) != '') { if (trim($passwdHide) != '') {
@@ -523,8 +524,10 @@ class adminProxy extends HttpProxyController
case 5: case 5:
if ($SendaTestMail == 'true') { if ($SendaTestMail == 'true') {
try { try {
$eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3}$/";
$_POST['FROM_NAME'] = G::LoadTranslation('ID_MESS_TEST_BODY'); $_POST['FROM_NAME'] = G::LoadTranslation('ID_MESS_TEST_BODY');
$_POST['FROM_EMAIL'] = $user; $_POST["FROM_EMAIL"] = ($fromMail != "" && preg_match($eregMail, $fromMail))? $fromMail : $user;
$_POST['MESS_ENGINE'] = 'PHPMAILER'; $_POST['MESS_ENGINE'] = 'PHPMAILER';
$_POST['MESS_SERVER'] = $server; $_POST['MESS_SERVER'] = $server;
$_POST['MESS_PORT'] = $port; $_POST['MESS_PORT'] = $port;
@@ -546,6 +549,7 @@ class adminProxy extends HttpProxyController
} }
*/ */
$resp = $this->sendTestMail(); $resp = $this->sendTestMail();
if ($resp->status == '1') { if ($resp->status == '1') {
$this->success=true; $this->success=true;
} else { } else {
@@ -576,7 +580,12 @@ class adminProxy extends HttpProxyController
G::LoadClass("system"); G::LoadClass("system");
G::LoadClass('spool'); G::LoadClass('spool');
$sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>'; $eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3}$/";
$fromNameAux = ($_POST["FROM_NAME"] != "")? $_POST["FROM_NAME"] . " " : "";
$fromMailAux = (preg_match($eregMail, $_POST["FROM_EMAIL"]))? "<" . $_POST["FROM_EMAIL"] . ">" : "";
$sFrom = $fromNameAux . $fromMailAux;
$sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT'); $sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT');
$msg = G::LoadTranslation('ID_MESS_TEST_BODY'); $msg = G::LoadTranslation('ID_MESS_TEST_BODY');
@@ -609,6 +618,7 @@ class adminProxy extends HttpProxyController
'MESS_PORT' => $_POST['MESS_PORT'], 'MESS_PORT' => $_POST['MESS_PORT'],
'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'], 'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'],
'MESS_PASSWORD' => $_POST['MESS_PASSWORD'], 'MESS_PASSWORD' => $_POST['MESS_PASSWORD'],
"FROM_EMAIL" => $_POST["FROM_EMAIL"],
'SMTPAuth' => $_POST['SMTPAuth'], 'SMTPAuth' => $_POST['SMTPAuth'],
'SMTPSecure' => isset($_POST['SMTPSecure'])?$_POST['SMTPSecure']:'none' 'SMTPSecure' => isset($_POST['SMTPSecure'])?$_POST['SMTPSecure']:'none'
) )
@@ -699,6 +709,8 @@ class adminProxy extends HttpProxyController
$aFields['MESS_FROM_NAME'] = $_POST['FromName']; $aFields['MESS_FROM_NAME'] = $_POST['FromName'];
$aFields['MESS_TRY_SEND_INMEDIATLY'] = $_POST['SendaTestMail'];//isset($_POST['form']['MESS_TRY_SEND_INMEDIATLY']) ? $_POST['form']['MESS_TRY_SEND_INMEDIATLY'] : ''; $aFields['MESS_TRY_SEND_INMEDIATLY'] = $_POST['SendaTestMail'];//isset($_POST['form']['MESS_TRY_SEND_INMEDIATLY']) ? $_POST['form']['MESS_TRY_SEND_INMEDIATLY'] : '';
$aFields['MESS_TRY_SEND_INMEDIATLY'] = ($aFields['MESS_TRY_SEND_INMEDIATLY'] == 'true') ? '1' : $aFields['MESS_TRY_SEND_INMEDIATLY']; $aFields['MESS_TRY_SEND_INMEDIATLY'] = ($aFields['MESS_TRY_SEND_INMEDIATLY'] == 'true') ? '1' : $aFields['MESS_TRY_SEND_INMEDIATLY'];
$aFields["MESS_FROM_MAIL"] = $_POST["fromMail"];
$CfgUid='Emails'; $CfgUid='Emails';
$ObjUid=''; $ObjUid='';
$ProUid=''; $ProUid='';

View File

@@ -32,9 +32,10 @@ Ext.onReady(function(){
Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('Password').setVisible(false); Ext.getCmp('Password').setVisible(false);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('UseSecureConnection').setVisible(false); Ext.getCmp('UseSecureConnection').setVisible(false);
Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp("fromMail").setVisible(false);
Ext.getCmp("fromMail").getEl().up('.x-form-item').setDisplayed(false);
} else { } else {
Ext.getCmp('Server').setVisible(true); Ext.getCmp('Server').setVisible(true);
Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // hide label Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // hide label
@@ -44,6 +45,8 @@ Ext.onReady(function(){
Ext.getCmp('RequireAuthentication').getEl().up('.x-form-item').setDisplayed(true); Ext.getCmp('RequireAuthentication').getEl().up('.x-form-item').setDisplayed(true);
Ext.getCmp('AccountFrom').setVisible(true); Ext.getCmp('AccountFrom').setVisible(true);
Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(true); Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(true);
Ext.getCmp("fromMail").setVisible(true);
Ext.getCmp("fromMail").getEl().up('.x-form-item').setDisplayed(true);
if (Ext.getCmp('RequireAuthentication').getValue() === true) if (Ext.getCmp('RequireAuthentication').getValue() === true)
{ {
@@ -98,6 +101,8 @@ Ext.onReady(function(){
Ext.getCmp('SendaTestMail').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('SendaTestMail').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('eFromName').setVisible(false); Ext.getCmp('eFromName').setVisible(false);
Ext.getCmp('eFromName').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('eFromName').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp("fromMail").setVisible(false);
Ext.getCmp("fromMail").getEl().up('.x-form-item').setDisplayed(false);
if (Ext.getCmp('SendaTestMail').getValue().checked) { if (Ext.getCmp('SendaTestMail').getValue().checked) {
Ext.getCmp('eMailto').setVisible(true); Ext.getCmp('eMailto').setVisible(true);
@@ -158,9 +163,10 @@ Ext.onReady(function(){
Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('Password').setVisible(false); Ext.getCmp('Password').setVisible(false);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('UseSecureConnection').setVisible(false); Ext.getCmp('UseSecureConnection').setVisible(false);
Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp("fromMail").setVisible(false);
Ext.getCmp("fromMail").getEl().up('.x-form-item').setDisplayed(false);
} else { } else {
Ext.getCmp('Server').setVisible(true); Ext.getCmp('Server').setVisible(true);
Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // hide label Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // hide label
@@ -171,6 +177,9 @@ Ext.onReady(function(){
Ext.getCmp('AccountFrom').setVisible(true); Ext.getCmp('AccountFrom').setVisible(true);
Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(true); Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(true);
Ext.getCmp("fromMail").setVisible(true);
Ext.getCmp("fromMail").getEl().up('.x-form-item').setDisplayed(true);
if (Ext.getCmp('RequireAuthentication').getValue() === true) if (Ext.getCmp('RequireAuthentication').getValue() === true)
{ {
Ext.getCmp('Password').setVisible(true); Ext.getCmp('Password').setVisible(true);
@@ -362,6 +371,37 @@ Ext.onReady(function(){
} }
} }
}, },
{
xtype: "textfield",
id: "fromMail",
name: "fromMail",
fieldLabel: "From Mail", //"From Mail",
width: 250,
disabled: true
},
{
xtype: 'textfield',
fieldLabel: _('ID_FROM_NAME'),
id:'eFromName',
name:'eFromName',
width: 250,
disabled : true
},
{
id:'UseSecureConnection',
name:'UseSecureConnection',
xtype: 'radiogroup',
fieldLabel: _('USE_SECURE_CONNECTION'),//'Use Secure Connection',
columns: 3,
width: 200,
disabled : true,
vertical: true,
items: [
{boxLabel: 'No',inputValue: 'No',name: 'UseSecureConnection',checked:true},
{boxLabel: 'TLS', inputValue: 'tls',name: 'UseSecureConnection'},
{boxLabel: 'SSL', inputValue: 'ssl',name: 'UseSecureConnection'}
]
},
{ {
xtype: 'checkbox', xtype: 'checkbox',
boxLabel: _('SEND_TEST_MAIL'),//'Send a test mail' , boxLabel: _('SEND_TEST_MAIL'),//'Send a test mail' ,
@@ -392,29 +432,7 @@ Ext.onReady(function(){
disabled : true, disabled : true,
allowBlank: false allowBlank: false
}, },
{ tb
xtype: 'textfield',
fieldLabel: _('ID_FROM_NAME'),
id:'eFromName',
name:'eFromName',
width: 250,
disabled : true
},
{
id:'UseSecureConnection',
name:'UseSecureConnection',
xtype: 'radiogroup',
fieldLabel: _('USE_SECURE_CONNECTION'),//'Use Secure Connection',
columns: 3,
width: 200,
disabled : true,
vertical: true,
items: [
{boxLabel: 'No',inputValue: 'No',name: 'UseSecureConnection',checked:true},
{boxLabel: 'TLS', inputValue: 'tls',name: 'UseSecureConnection'},
{boxLabel: 'SSL', inputValue: 'ssl',name: 'UseSecureConnection'}
]
},tb
] ]
}); });
@@ -448,6 +466,9 @@ Ext.onReady(function(){
Ext.getCmp('UseSecureConnection').setVisible(false); Ext.getCmp('UseSecureConnection').setVisible(false);
Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp("fromMail").setVisible(false);
Ext.getCmp("fromMail").getEl().up('.x-form-item').setDisplayed(false);
} else { } else {
Ext.getCmp('Server').setVisible(true); Ext.getCmp('Server').setVisible(true);
Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // hide label Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // hide label
@@ -457,6 +478,8 @@ Ext.onReady(function(){
Ext.getCmp('RequireAuthentication').getEl().up('.x-form-item').setDisplayed(true); Ext.getCmp('RequireAuthentication').getEl().up('.x-form-item').setDisplayed(true);
Ext.getCmp('AccountFrom').setVisible(true); Ext.getCmp('AccountFrom').setVisible(true);
Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(true); Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(true);
Ext.getCmp("fromMail").setVisible(true);
Ext.getCmp("fromMail").getEl().up('.x-form-item').setDisplayed(true);
if (Ext.getCmp('RequireAuthentication').getValue() === true) if (Ext.getCmp('RequireAuthentication').getValue() === true)
{ {
@@ -486,6 +509,12 @@ Ext.onReady(function(){
Ext.getCmp('Password').setValue(res.data.MESS_PASSWORD); Ext.getCmp('Password').setValue(res.data.MESS_PASSWORD);
Ext.getCmp('PasswordHide').setValue(Ext.getCmp('Password').getValue()); Ext.getCmp('PasswordHide').setValue(Ext.getCmp('Password').getValue());
if (typeof (res.data.MESS_FROM_MAIL) != "undefined"){
Ext.getCmp("fromMail").setValue(res.data.MESS_FROM_MAIL);
} else {
Ext.getCmp("fromMail").setValue("");
}
if (res.data.SMTPSecure == 'none') { if (res.data.SMTPSecure == 'none') {
Ext.getCmp('UseSecureConnection').setValue('No'); Ext.getCmp('UseSecureConnection').setValue('No');
} }
@@ -559,6 +588,9 @@ Ext.onReady(function(){
Ext.getCmp('SaveChanges').setVisible(false); Ext.getCmp('SaveChanges').setVisible(false);
Ext.getCmp('UnEdit').setVisible(false); Ext.getCmp('UnEdit').setVisible(false);
Ext.getCmp('labelUn').setVisible(false); Ext.getCmp('labelUn').setVisible(false);
Ext.getCmp("fromMail").setVisible(false);
Ext.getCmp("fromMail").getEl().up('.x-form-item').setDisplayed(false);
}); });
var testConnForm = new Ext.FormPanel({ var testConnForm = new Ext.FormPanel({
@@ -760,6 +792,7 @@ var EditMethod = function()
Ext.getCmp('Edit').setVisible(false); Ext.getCmp('Edit').setVisible(false);
Ext.getCmp('label').setVisible(false); Ext.getCmp('label').setVisible(false);
Ext.getCmp('labelUn').setVisible(true); Ext.getCmp('labelUn').setVisible(true);
Ext.getCmp("fromMail").setDisabled(false);
} }
var UnEditMethod = function() var UnEditMethod = function()
@@ -781,10 +814,12 @@ var UnEditMethod = function()
Ext.getCmp('Edit').setVisible(true); Ext.getCmp('Edit').setVisible(true);
Ext.getCmp('label').setVisible(true); Ext.getCmp('label').setVisible(true);
Ext.getCmp('labelUn').setVisible(false); Ext.getCmp('labelUn').setVisible(false);
Ext.getCmp("fromMail").setDisabled(true);
} }
var testMethod = function() var testMethod = function()
{ {
var typeTest = Ext.getCmp('EmailEngine').getValue(); var typeTest = Ext.getCmp('EmailEngine').getValue();
switch (typeTest) switch (typeTest)
{ {
case 'MAIL': case 'MAIL':
@@ -855,7 +890,8 @@ var testMethod = function()
UseSecureCon : UseSecureConnection, UseSecureCon : UseSecureConnection,
SendaTestMail : Ext.getCmp('SendaTestMail').getValue() , SendaTestMail : Ext.getCmp('SendaTestMail').getValue() ,
eMailto : Ext.getCmp('eMailto').getValue(), eMailto : Ext.getCmp('eMailto').getValue(),
login : Ext.getCmp('AccountFrom').getValue() login : Ext.getCmp('AccountFrom').getValue(),
fromMail : Ext.getCmp("fromMail").getValue()
}; };
Ext.getCmp('step1').setText('<span id="rstep1"></span> '+_('RESOLVING_NAME')+' <b>'+params.server+'</b>', false); Ext.getCmp('step1').setText('<span id="rstep1"></span> '+_('RESOLVING_NAME')+' <b>'+params.server+'</b>', false);
@@ -889,7 +925,6 @@ var testMethod = function()
}; };
function execTest(step) { function execTest(step) {
if (step == 6) return false; if (step == 6) return false;
if (step == 13) return false; if (step == 13) return false;
@@ -956,7 +991,8 @@ saveMethod=function() {
FromName: Ext.getCmp('eFromName').getValue(), FromName: Ext.getCmp('eFromName').getValue(),
EnableEmailNotifications : Ext.getCmp('EnableEmailNotifications').getValue(), EnableEmailNotifications : Ext.getCmp('EnableEmailNotifications').getValue(),
EmailEngine : Ext.getCmp('EmailEngine').getValue(), EmailEngine : Ext.getCmp('EmailEngine').getValue(),
background: 'true' background: 'true',
fromMail:Ext.getCmp("fromMail").getValue()
}, },
success: function(r){ success: function(r){
var i = Ext.decode(r.responseText); var i = Ext.decode(r.responseText);