mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Merge branch 'ent-7300-email-test-solo-envia-datos-guardados' into 'develop'
Email test working with data in text fields See merge request artica/pandorafms!4090
This commit is contained in:
commit
44ea35bb69
@ -34,9 +34,11 @@ check_login();
|
|||||||
|
|
||||||
if (is_ajax()) {
|
if (is_ajax()) {
|
||||||
$test_address = get_parameter('test_address', '');
|
$test_address = get_parameter('test_address', '');
|
||||||
|
$params = get_parameter('params', '');
|
||||||
|
|
||||||
$res = send_test_email(
|
$res = send_test_email(
|
||||||
$test_address
|
$test_address,
|
||||||
|
$params
|
||||||
);
|
);
|
||||||
|
|
||||||
echo $res;
|
echo $res;
|
||||||
@ -709,12 +711,25 @@ function perform_email_test () {
|
|||||||
$('#email_test_failure_message').hide();
|
$('#email_test_failure_message').hide();
|
||||||
|
|
||||||
var test_address = $('#text-email_test_address').val();
|
var test_address = $('#text-email_test_address').val();
|
||||||
|
params = {
|
||||||
|
email_smtpServer : $('#text-email_smtpServer').val(),
|
||||||
|
email_smtpPort : $('#text-email_smtpPort').val(),
|
||||||
|
email_username : $('#text-email_username').val(),
|
||||||
|
email_password : $('#password-email_password').val(),
|
||||||
|
email_encryption : $( "#email_encryption option:selected" ).val(),
|
||||||
|
email_from_dir : $('#text-email_from_dir').val(),
|
||||||
|
email_from_name : $('#text-email_from_name').val()
|
||||||
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "ajax.php",
|
url: "ajax.php",
|
||||||
data: "page=godmode/setup/setup_general&test_address="+test_address,
|
data : {
|
||||||
dataType: "html",
|
page: "godmode/setup/setup_general",
|
||||||
|
test_address: test_address,
|
||||||
|
params: params
|
||||||
|
},
|
||||||
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (parseInt(data) === 1) {
|
if (parseInt(data) === 1) {
|
||||||
$('#email_test_sent_message').show();
|
$('#email_test_sent_message').show();
|
||||||
|
@ -5940,26 +5940,56 @@ function get_data_multiplier($unit)
|
|||||||
* Send test email to check email setups.
|
* Send test email to check email setups.
|
||||||
*
|
*
|
||||||
* @param string $to Target email account.
|
* @param string $to Target email account.
|
||||||
|
* @param array $params Array with connection data.
|
||||||
|
* Available fields:
|
||||||
|
* 'email_smtpServer',
|
||||||
|
* 'email_smtpPort',
|
||||||
|
* 'email_username',
|
||||||
|
* 'email_password',
|
||||||
|
* 'email_encryption',
|
||||||
|
* 'email_from_dir',
|
||||||
|
* 'email_from_name',
|
||||||
*
|
*
|
||||||
* @return integer Status of the email send task.
|
* @return integer Status of the email send task.
|
||||||
*/
|
*/
|
||||||
function send_test_email(
|
function send_test_email(
|
||||||
string $to
|
string $to,
|
||||||
|
array $params=null
|
||||||
) {
|
) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
$valid_params = [
|
||||||
|
'email_smtpServer',
|
||||||
|
'email_smtpPort',
|
||||||
|
'email_username',
|
||||||
|
'email_password',
|
||||||
|
'email_encryption',
|
||||||
|
'email_from_dir',
|
||||||
|
'email_from_name',
|
||||||
|
];
|
||||||
|
|
||||||
|
if (empty($params) === true) {
|
||||||
|
foreach ($valid_params as $token) {
|
||||||
|
$params[$token] = $config[$token];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (array_diff($valid_params, array_keys($params)) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$result = false;
|
$result = false;
|
||||||
try {
|
try {
|
||||||
$transport = new Swift_SmtpTransport(
|
$transport = new Swift_SmtpTransport(
|
||||||
$config['email_smtpServer'],
|
$params['email_smtpServer'],
|
||||||
$config['email_smtpPort']
|
$params['email_smtpPort']
|
||||||
);
|
);
|
||||||
|
|
||||||
$transport->setUsername($config['email_username']);
|
$transport->setUsername($params['email_username']);
|
||||||
$transport->setPassword($config['email_password']);
|
$transport->setPassword($params['email_password']);
|
||||||
|
|
||||||
if ($config['email_encryption']) {
|
if ($params['email_encryption']) {
|
||||||
$transport->setEncryption($config['email_encryption']);
|
$transport->setEncryption($params['email_encryption']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mailer = new Swift_Mailer($transport);
|
$mailer = new Swift_Mailer($transport);
|
||||||
@ -5968,8 +5998,8 @@ function send_test_email(
|
|||||||
|
|
||||||
$message->setFrom(
|
$message->setFrom(
|
||||||
[
|
[
|
||||||
$config['email_from_dir'] => io_safe_output(
|
$params['email_from_dir'] => io_safe_output(
|
||||||
$config['email_from_name']
|
$params['email_from_name']
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user