Allow test mail configuration - refs #8308
parent
5f6730f5e6
commit
439008d4c5
@ -0,0 +1,65 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
/** |
||||||
|
* Index page of the admin tools |
||||||
|
* @package chamilo.admin |
||||||
|
*/ |
||||||
|
// Resetting the course id. |
||||||
|
$cidReset = true; |
||||||
|
|
||||||
|
// Including some necessary chamilo files. |
||||||
|
require_once '../inc/global.inc.php'; |
||||||
|
|
||||||
|
api_protect_admin_script(); |
||||||
|
|
||||||
|
// Setting the section (for the tabs). |
||||||
|
$this_section = SECTION_PLATFORM_ADMIN; |
||||||
|
$toolName = get_lang('EMailTester'); |
||||||
|
|
||||||
|
$form = new FormValidator('email_tester'); |
||||||
|
$form->addText('smtp_host', get_lang('Host'), false, ['cols-size' => [3, 8, 1]]); |
||||||
|
$form->addText('smtp_port', get_lang('Port'), false, ['cols-size' => [3, 8, 1]]); |
||||||
|
$form->addText('destination', get_lang('Destination'), true, ['cols-size' => [3, 8, 1]]); |
||||||
|
$form->addText('subject', get_lang('Subject'), true, ['cols-size' => [3, 8, 1]]); |
||||||
|
$form->addHtmlEditor('content', get_lang('Message'), true, false, ['ToolbarSet' => 'Minimal', 'cols-size' => [3, 8, 1]]); |
||||||
|
$form->addButtonSend(get_lang('SendMessage'), 'submit', false, ['cols-size' => [3, 8, 1]]); |
||||||
|
$form->setDefaults([ |
||||||
|
'smtp_host' => $platform_email['SMTP_HOST'], |
||||||
|
'smtp_port' => $platform_email['SMTP_PORT'] |
||||||
|
]); |
||||||
|
$form->freeze(['smtp_host', 'smtp_port']); |
||||||
|
|
||||||
|
$errorsInfo = MessageManager::failedSentMailErrors(); |
||||||
|
|
||||||
|
if ($form->validate()) { |
||||||
|
$values = $form->exportValues(); |
||||||
|
|
||||||
|
$user = api_get_user_entity(api_get_user_id()); |
||||||
|
|
||||||
|
$mailIsSent = api_mail_html( |
||||||
|
get_lang('UserTestingEMailConf'), |
||||||
|
$values['destination'], |
||||||
|
$values['subject'], |
||||||
|
$values['content'], |
||||||
|
$user->getCompleteName(), |
||||||
|
$user->getEmail() |
||||||
|
); |
||||||
|
|
||||||
|
Display::addFlash( |
||||||
|
Display::return_message(get_lang('MailingTestSent'), 'warning') |
||||||
|
); |
||||||
|
|
||||||
|
header('Location: ' . api_get_self()); |
||||||
|
exit; |
||||||
|
} |
||||||
|
|
||||||
|
$view = new Template($toolName); |
||||||
|
$view->assign('form', $form->returnForm()); |
||||||
|
$view->assign('errors', $errorsInfo); |
||||||
|
|
||||||
|
$template = $view->get_template('admin/email_tester.tpl'); |
||||||
|
$content = $view->fetch($template); |
||||||
|
|
||||||
|
$view->assign('header', $toolName); |
||||||
|
$view->assign('content', $content); |
||||||
|
$view->display_one_col_template(); |
@ -0,0 +1,19 @@ |
|||||||
|
<div class="row"> |
||||||
|
<div class="col-sm-5"> |
||||||
|
{{ form }} |
||||||
|
</div> |
||||||
|
{% if not errors is empty %} |
||||||
|
<div class="col-sm-7"> |
||||||
|
<h4 class="page-header">{{ 'Errors'|get_lang }}</h4> |
||||||
|
<ul> |
||||||
|
{% for error in errors %} |
||||||
|
<li> |
||||||
|
{{ 'Email: %s. %s ago'|format(error.mail, error.time) }} |
||||||
|
<pre>{{ error.reason|replace({'\n': '<br>'}) }}</pre> |
||||||
|
</li> |
||||||
|
{% endfor %} |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
|
Loading…
Reference in new issue