From 3cf5e5caa9cc166f37c0ef0c9f91866a79bd881e Mon Sep 17 00:00:00 2001 From: Luis Fernando Saisa Lopez Date: Mon, 28 Apr 2014 17:02:38 -0400 Subject: [PATCH] =?UTF-8?q?BUG=2014723=20"Error=20en=20la=20configuraci?= =?UTF-8?q?=C3=B3e=20un=20correo..."=20SOLVED?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- workflow/engine/classes/class.spool.php | 9 ++- workflow/engine/controllers/adminProxy.php | 16 +++- workflow/engine/templates/admin/emails.js | 92 +++++++++++++++------- 3 files changed, 85 insertions(+), 32 deletions(-) diff --git a/workflow/engine/classes/class.spool.php b/workflow/engine/classes/class.spool.php index c0d505257..54ad9f5ab 100755 --- a/workflow/engine/classes/class.spool.php +++ b/workflow/engine/classes/class.spool.php @@ -251,9 +251,13 @@ class spoolRun */ private function handleFrom () { + $eregA = "/^.*@.*$/"; + if (strpos( $this->fileData['from'], '<' ) !== false) { //to validate complex email address i.e. Erik A. O - 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] != '') { //drop the " characters if they exist $this->fileData['from_name'] = trim( str_replace( '"', '', $matches[1] ) ); @@ -269,7 +273,8 @@ class spoolRun $this->fileData['from_email'] = trim( $matches[3] ); } else { //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] )) { throw new Exception( 'Invalid email address in FROM parameter (' . $this->fileData['from'] . ')', $this->ExceptionCode['WARNING'] ); diff --git a/workflow/engine/controllers/adminProxy.php b/workflow/engine/controllers/adminProxy.php index b15d3e4e5..62516d01c 100644 --- a/workflow/engine/controllers/adminProxy.php +++ b/workflow/engine/controllers/adminProxy.php @@ -403,6 +403,7 @@ class adminProxy extends HttpProxyController $server = $_POST['server']; $user = $_POST['user']; $passwd = $_POST['passwd']; + $fromMail = $_POST["fromMail"]; $passwdHide = $_POST['passwdHide']; if (trim($passwdHide) != '') { @@ -523,8 +524,10 @@ class adminProxy extends HttpProxyController case 5: if ($SendaTestMail == 'true') { 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_EMAIL'] = $user; + $_POST["FROM_EMAIL"] = ($fromMail != "" && preg_match($eregMail, $fromMail))? $fromMail : $user; $_POST['MESS_ENGINE'] = 'PHPMAILER'; $_POST['MESS_SERVER'] = $server; $_POST['MESS_PORT'] = $port; @@ -546,6 +549,7 @@ class adminProxy extends HttpProxyController } */ $resp = $this->sendTestMail(); + if ($resp->status == '1') { $this->success=true; } else { @@ -576,7 +580,12 @@ class adminProxy extends HttpProxyController G::LoadClass("system"); 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'); $msg = G::LoadTranslation('ID_MESS_TEST_BODY'); @@ -609,6 +618,7 @@ class adminProxy extends HttpProxyController 'MESS_PORT' => $_POST['MESS_PORT'], 'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'], 'MESS_PASSWORD' => $_POST['MESS_PASSWORD'], + "FROM_EMAIL" => $_POST["FROM_EMAIL"], 'SMTPAuth' => $_POST['SMTPAuth'], 'SMTPSecure' => isset($_POST['SMTPSecure'])?$_POST['SMTPSecure']:'none' ) @@ -699,6 +709,8 @@ class adminProxy extends HttpProxyController $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'] = ($aFields['MESS_TRY_SEND_INMEDIATLY'] == 'true') ? '1' : $aFields['MESS_TRY_SEND_INMEDIATLY']; + $aFields["MESS_FROM_MAIL"] = $_POST["fromMail"]; + $CfgUid='Emails'; $ObjUid=''; $ProUid=''; diff --git a/workflow/engine/templates/admin/emails.js b/workflow/engine/templates/admin/emails.js index f317aae6d..598925cab 100644 --- a/workflow/engine/templates/admin/emails.js +++ b/workflow/engine/templates/admin/emails.js @@ -32,9 +32,10 @@ Ext.onReady(function(){ Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('Password').setVisible(false); Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false); - Ext.getCmp('UseSecureConnection').setVisible(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 { Ext.getCmp('Server').setVisible(true); 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('AccountFrom').setVisible(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) { @@ -98,6 +101,8 @@ Ext.onReady(function(){ Ext.getCmp('SendaTestMail').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('eFromName').setVisible(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) { Ext.getCmp('eMailto').setVisible(true); @@ -158,9 +163,10 @@ Ext.onReady(function(){ Ext.getCmp('AccountFrom').getEl().up('.x-form-item').setDisplayed(false); Ext.getCmp('Password').setVisible(false); Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false); - Ext.getCmp('UseSecureConnection').setVisible(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 { Ext.getCmp('Server').setVisible(true); 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').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) { 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', boxLabel: _('SEND_TEST_MAIL'),//'Send a test mail' , @@ -392,29 +432,7 @@ Ext.onReady(function(){ disabled : true, allowBlank: false }, - { - 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 + tb ] }); @@ -448,6 +466,9 @@ Ext.onReady(function(){ Ext.getCmp('UseSecureConnection').setVisible(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 { Ext.getCmp('Server').setVisible(true); 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('AccountFrom').setVisible(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) { @@ -486,6 +509,12 @@ Ext.onReady(function(){ Ext.getCmp('Password').setValue(res.data.MESS_PASSWORD); 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') { Ext.getCmp('UseSecureConnection').setValue('No'); } @@ -559,6 +588,9 @@ Ext.onReady(function(){ Ext.getCmp('SaveChanges').setVisible(false); Ext.getCmp('UnEdit').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({ @@ -760,6 +792,7 @@ var EditMethod = function() Ext.getCmp('Edit').setVisible(false); Ext.getCmp('label').setVisible(false); Ext.getCmp('labelUn').setVisible(true); + Ext.getCmp("fromMail").setDisabled(false); } var UnEditMethod = function() @@ -781,10 +814,12 @@ var UnEditMethod = function() Ext.getCmp('Edit').setVisible(true); Ext.getCmp('label').setVisible(true); Ext.getCmp('labelUn').setVisible(false); + Ext.getCmp("fromMail").setDisabled(true); } var testMethod = function() { var typeTest = Ext.getCmp('EmailEngine').getValue(); + switch (typeTest) { case 'MAIL': @@ -855,7 +890,8 @@ var testMethod = function() UseSecureCon : UseSecureConnection, SendaTestMail : Ext.getCmp('SendaTestMail').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(' '+_('RESOLVING_NAME')+' '+params.server+'', false); @@ -889,7 +925,6 @@ var testMethod = function() }; function execTest(step) { - if (step == 6) return false; if (step == 13) return false; @@ -956,7 +991,8 @@ saveMethod=function() { FromName: Ext.getCmp('eFromName').getValue(), EnableEmailNotifications : Ext.getCmp('EnableEmailNotifications').getValue(), EmailEngine : Ext.getCmp('EmailEngine').getValue(), - background: 'true' + background: 'true', + fromMail:Ext.getCmp("fromMail").getValue() }, success: function(r){ var i = Ext.decode(r.responseText);