forked from joomla/joomla-cms
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request joomla#8643 from Kubik-Rubik/feature-sendtestmail
Feature - Send Test Mail
- Loading branch information
Showing
5 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
administrator/components/com_config/controller/application/sendtestmail.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_config | ||
* | ||
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* Send Test Mail Controller from global configuration | ||
* | ||
* @since 3.6 | ||
*/ | ||
class ConfigControllerApplicationSendtestmail extends JControllerBase | ||
{ | ||
/** | ||
* Method to send the test mail. | ||
* | ||
* @return string | ||
* | ||
* @since 3.6 | ||
*/ | ||
public function execute() | ||
{ | ||
if (!JSession::checkToken('get')) | ||
{ | ||
$this->app->enqueueMessage(JText::_('JINVALID_TOKEN')); | ||
$this->app->redirect('index.php'); | ||
} | ||
|
||
if (!JFactory::getUser()->authorise('core.admin')) | ||
{ | ||
$this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR')); | ||
$this->app->redirect('index.php'); | ||
} | ||
|
||
$model = new ConfigModelApplication; | ||
echo new JResponseJson($model->sendTestMail()); | ||
JFactory::getApplication()->close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* @package Joomla.JavaScript | ||
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
/** | ||
* Calls the sending process of the config class | ||
*/ | ||
jQuery(document).ready(function ($) | ||
{ | ||
$('#sendtestmail').click(function () | ||
{ | ||
var email_data = { | ||
smtpauth : $('input[name="jform[smtpauth]"]').val(), | ||
smtpuser : $('input[name="jform[smtpuser]"]').val(), | ||
smtppass : $('input[name="jform[smtppass]"]').val(), | ||
smtphost : $('input[name="jform[smtphost]"]').val(), | ||
smtpsecure: $('select[name="jform[smtpsecure]"]').val(), | ||
smtpport : $('input[name="jform[smtpport]"]').val(), | ||
mailfrom : $('input[name="jform[mailfrom]"]').val(), | ||
fromname : $('input[name="jform[fromname]"]').val(), | ||
mailer : $('select[name="jform[mailer]"]').val(), | ||
mailonline: $('input[name="jform[mailonline]"]:checked').val() | ||
}; | ||
|
||
$.ajax({ | ||
url: sendtestmail_url, | ||
data: email_data | ||
}) | ||
|
||
.done(function (response) | ||
{ | ||
var data_response = $.parseJSON(response); | ||
var msg = {}; | ||
|
||
if (data_response.data) | ||
{ | ||
if (typeof data_response.messages == 'object') | ||
{ | ||
if (typeof data_response.messages.success != 'undefined' && data_response.messages.success.length > 0) | ||
{ | ||
msg.success = [data_response.messages.success]; | ||
} | ||
} | ||
|
||
} | ||
else | ||
{ | ||
if (typeof data_response.messages == 'object') | ||
{ | ||
if (typeof data_response.messages.error != 'undefined' && data_response.messages.error.length > 0) | ||
{ | ||
msg.error = [data_response.messages.error]; | ||
} | ||
|
||
if (typeof data_response.messages.notice != 'undefined' && data_response.messages.notice.length > 0) | ||
{ | ||
msg.notice = [data_response.messages.notice]; | ||
} | ||
|
||
if (typeof data_response.messages.message != 'undefined' && data_response.messages.message.length > 0) | ||
{ | ||
msg.message = [data_response.messages.message]; | ||
} | ||
} | ||
} | ||
|
||
Joomla.renderMessages(msg); | ||
}); | ||
|
||
window.scrollTo(0, 0); | ||
}); | ||
}); |