BUG 8847 The option mail php is disabled SOLVED

- I add option mail php to send mail
This commit is contained in:
Brayan Osmar Pereyra Suxo
2012-06-13 18:14:18 -04:00
parent be15de83e5
commit 37a7b5e091
3 changed files with 338 additions and 158 deletions

View File

@@ -583,7 +583,6 @@ class PHPMailer {
if ($this->exceptions) {
throw $e;
}
echo $e->getMessage()."\n";
return false;
}
}

View File

@@ -346,6 +346,38 @@ class adminProxy extends HttpProxyController
G::LoadClass('net');
G::LoadThirdParty('phpmailer', 'class.smtp');
if ($_POST['typeTest'] == 'MAIL')
{
define("SUCCESSFUL", 'SUCCESSFUL');
define("FAILED", 'FAILED');
$mail_to = $_POST['mail_to'];
$send_test_mail = $_POST['send_test_mail'];
$_POST['FROM_NAME'] = $mail_to;
$_POST['FROM_EMAIL'] = $mail_to;
$_POST['MESS_ENGINE'] = 'MAIL';
$_POST['MESS_SERVER'] = 'localhost';
$_POST['MESS_PORT'] = 25;
$_POST['MESS_ACCOUNT'] = $mail_to;
$_POST['MESS_PASSWORD'] = '';
$_POST['TO'] = $mail_to;
$_POST['SMTPAuth'] = true;
try {
$resp = $this->sendTestMail();
} catch (Exception $error) {
$resp = new stdclass();
$reps->status = false;
$resp->msg = $error->getMessage();
}
if($resp->status){
echo '{"sendMail":true, "msg":"' . $resp->msg . '"}';
} else {
echo '{"sendMail":false, "msg":"' . $resp->msg . '"}';
}
die;
}
$step = $_POST['step'];
$server = $_POST['server'];
$user = $_POST['user'];

View File

@@ -8,19 +8,50 @@ Ext.onReady(function(){
listeners: {
check: function(EnableEmailNotifications, checked) {
if(checked) {
loadfields();
combo.setVisible(true);
combo.getEl().up('.x-form-item').setDisplayed(true); // show label
if (Ext.getCmp('EmailEngine').getValue()== 'MAIL') {
Ext.getCmp('Server').setVisible(false);
Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(false); // hide label
Ext.getCmp('Port').setVisible(false);
Ext.getCmp('Port').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('RequireAuthentication').setVisible(false);
Ext.getCmp('RequireAuthentication').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('AccountFrom').setVisible(false);
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);
} else {
Ext.getCmp('Server').setVisible(true);
Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // show label
Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // hide label
Ext.getCmp('Port').setVisible(true);
Ext.getCmp('Port').getEl().up('.x-form-item').setDisplayed(true);
Ext.getCmp('RequireAuthentication').setVisible(true);
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);
if (Ext.getCmp('RequireAuthentication').getValue() === true)
{
Ext.getCmp('Password').setVisible(true);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(true);
} else {
Ext.getCmp('Password').setVisible(false);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false);
}
if(!Ext.getCmp('UseSecureConnection').getValue()) {
Ext.getCmp('UseSecureConnection').setValue('No');
}
Ext.getCmp('UseSecureConnection').setVisible(true);
Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(true);
}
Ext.getCmp('SendaTestMail').setVisible(true);
Ext.getCmp('SendaTestMail').getEl().up('.x-form-item').setDisplayed(true);
@@ -34,12 +65,6 @@ Ext.onReady(function(){
Ext.getCmp('eMailto').setValue(' ');
}
if(!Ext.getCmp('UseSecureConnection').getValue()) {
Ext.getCmp('UseSecureConnection').setValue('No');
}
Ext.getCmp('UseSecureConnection').setVisible(true);
Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(true);
}
else {
combo.setVisible(false);
@@ -98,6 +123,7 @@ Ext.onReady(function(){
displayField:'EmailEngine',
mode: 'local',
triggerAction: 'all',
value: 'PHPMAILER',
disabled : true,
listeners: {
select: function(combo, value) {
@@ -112,8 +138,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);
}
else {
Ext.getCmp('UseSecureConnection').setVisible(false);
Ext.getCmp('UseSecureConnection').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
Ext.getCmp('Port').setVisible(true);
@@ -122,9 +150,23 @@ 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);
if (Ext.getCmp('RequireAuthentication').getValue() === true)
{
Ext.getCmp('Password').setVisible(true);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(true);
} else {
Ext.getCmp('Password').setVisible(false);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false);
}
if(!Ext.getCmp('UseSecureConnection').getValue()) {
Ext.getCmp('UseSecureConnection').setValue('No');
}
Ext.getCmp('UseSecureConnection').setVisible(true);
Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(true);
}
}
}
});
@@ -216,8 +258,7 @@ Ext.onReady(function(){
if (this.checked) {
Ext.getCmp('Password').setVisible(true);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(true);
}
else {
} else {
Ext.getCmp('Password').setVisible(false);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('Password').setValue('');
@@ -322,12 +363,62 @@ Ext.onReady(function(){
if (res.success) {
Ext.getCmp('EnableEmailNotifications').setValue(res.data.MESS_ENABLED);
Ext.getCmp('EmailEngine').setValue(res.data.MESS_ENGINE);
if (Ext.getCmp('EmailEngine').getValue()== 'MAIL') {
Ext.getCmp('Server').setVisible(false);
Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(false); // hide label
Ext.getCmp('Port').setVisible(false);
Ext.getCmp('Port').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('RequireAuthentication').setVisible(false);
Ext.getCmp('RequireAuthentication').getEl().up('.x-form-item').setDisplayed(false);
Ext.getCmp('AccountFrom').setVisible(false);
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);
} else {
Ext.getCmp('Server').setVisible(true);
Ext.getCmp('Server').getEl().up('.x-form-item').setDisplayed(true); // hide label
Ext.getCmp('Port').setVisible(true);
Ext.getCmp('Port').getEl().up('.x-form-item').setDisplayed(true);
Ext.getCmp('RequireAuthentication').setVisible(true);
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);
if (Ext.getCmp('RequireAuthentication').getValue() === true)
{
Ext.getCmp('Password').setVisible(true);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(true);
} else {
Ext.getCmp('Password').setVisible(false);
Ext.getCmp('Password').getEl().up('.x-form-item').setDisplayed(false);
}
if(!Ext.getCmp('UseSecureConnection').getValue()) {
Ext.getCmp('UseSecureConnection').setValue('No');
}
Ext.getCmp('UseSecureConnection').setVisible(true);
Ext.getCmp('UseSecureConnection').getEl().up('.x-form-item').setDisplayed(true);
Ext.getCmp('Server').setValue(res.data.MESS_SERVER);
Ext.getCmp('Port').setValue(res.data.MESS_PORT);
Ext.getCmp('RequireAuthentication').setValue(res.data.MESS_RAUTH);
Ext.getCmp('AccountFrom').setValue(res.data.MESS_ACCOUNT);
Ext.getCmp('Password').setValue(res.data.MESS_PASSWORD);
Ext.getCmp('PasswordHide').setValue(Ext.getCmp('Password').getValue());
if (res.data.SMTPSecure == 'none') {
Ext.getCmp('UseSecureConnection').setValue('No');
}
else {
Ext.getCmp('UseSecureConnection').setValue(res.data.SMTPSecure);
}
}
Ext.getCmp('SendaTestMail').setValue(res.data.MESS_TRY_SEND_INMEDIATLY);
if(!res.data.MAIL_TO) {
@@ -336,13 +427,6 @@ Ext.onReady(function(){
else {
Ext.getCmp('eMailto').setValue(res.data.MAIL_TO);
}
if (res.data.SMTPSecure == 'none') {
Ext.getCmp('UseSecureConnection').setValue('No');
}
else {
Ext.getCmp('UseSecureConnection').setValue(res.data.SMTPSecure);
}
}
}
});
@@ -496,9 +580,9 @@ var testConnForm = new Ext.FormPanel({
var testEmailWindow = new Ext.Window({
width: 470,
closable:false,
plain: true,
autoHeight: true,
layout: 'fit',
plain: true,
y: 82,
items: testConnForm
});
@@ -546,6 +630,67 @@ var UnEditMethod = function()
}
var testMethod = function()
{
var typeTest = Ext.getCmp('EmailEngine').getValue();
switch (typeTest)
{
case 'MAIL':
Ext.MessageBox.show({
msg: _('ID_LOADING'),
progressText: 'Saving...',
width:300,
wait:true,
waitConfig: {interval:200},
animEl: 'mb7'
});
params = {
typeTest : 'MAIL',
request : 'mailTestMail_Show',
mail_to : Ext.getCmp('eMailto').getValue(),
send_test_mail : 'yes'
};
Ext.Ajax.request({
url: '../adminProxy/testConnection',
method:'POST',
params: params,
waitMsg: _('ID_LOADING'),
success: function(r,o) {
Ext.MessageBox.hide();
var resp = Ext.util.JSON.decode(r.responseText);
if (resp.sendMail === true) {
Ext.MessageBox.show({
title: 'Correct test mail',
msg: resp.msg,
buttons: Ext.MessageBox.OK,
animEl: 'mb9',
icon: Ext.MessageBox.INFO
});
Ext.getCmp('SaveChanges').enable();
} else {
Ext.MessageBox.show({
title: 'Error',
msg: resp.msg,
buttons: Ext.MessageBox.OK,
animEl: 'mb9',
icon: Ext.MessageBox.ERROR
});
Ext.getCmp('SaveChanges').disable();
}
},
failure: function () {
Ext.MessageBox.show({
title: 'Error',
msg: 'Error in connection',
buttons: Ext.MessageBox.OK,
animEl: 'mb9',
icon: Ext.MessageBox.ERROR
});
Ext.getCmp('SaveChanges').disable();
}
});
break;
case 'PHPMAILER':
if((Ext.getCmp('Port').getValue()==null)||(Ext.getCmp('Port').getValue()=='')) {
Ext.getCmp('Port').setValue('25');
}
@@ -564,6 +709,7 @@ var testMethod = function()
var create=true;
params = {
typeTest : 'PHPMAILER',
server : Ext.getCmp('Server').getValue(),
user : Ext.getCmp('AccountFrom').getValue(),
passwd : Ext.getCmp('Password').getValue(),
@@ -596,12 +742,15 @@ var testMethod = function()
Ext.getCmp('done').enable();
Ext.getCmp('SaveChanges').disable();
Ext.getCmp('EMailFields').disable();
testEmailWindow.show();
Ext.getCmp('EMailFields').enable();
execTest(1);
return true;
break;
}
return true;
};
function execTest(step) {