diff options
Diffstat (limited to 'classes/pref/system.php')
-rw-r--r-- | classes/pref/system.php | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/classes/pref/system.php b/classes/pref/system.php index 85635e753..c79b5095d 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -14,6 +14,20 @@ class Pref_System extends Handler_Administrative { $this->pdo->query("DELETE FROM ttrss_error_log"); } + function sendTestEmail() { + $mail_address = clean($_REQUEST["mail_address"]); + + $mailer = new Mailer(); + + $rc = $mailer->mail(["to_name" => "", + "to_address" => $mail_address, + "subject" => __("Test message from tt-rss"), + "message" => ("This message confirms that tt-rss can send outgoing mail.") + ]); + + print json_encode(['rc' => $rc, 'error' => $mailer->error()]); + } + function getphpinfo() { ob_start(); phpinfo(); @@ -103,12 +117,12 @@ class Pref_System extends Handler_Administrative { <table width='100%' class='event-log'> - <tr class='title'> - <td width='5%'><?= __("Error") ?></td> - <td><?= __("Filename") ?></td> - <td><?= __("Message") ?></td> - <td width='5%'><?= __("User") ?></td> - <td width='5%'><?= __("Date") ?></td> + <tr> + <th width='5%'><?= __("Error") ?></th> + <th><?= __("Filename") ?></th> + <th><?= __("Message") ?></th> + <th width='5%'><?= __("User") ?></th> + <th width='5%'><?= __("Date") ?></th> </tr> <?php @@ -151,16 +165,48 @@ class Pref_System extends Handler_Administrative { $page = (int) ($_REQUEST["page"] ?? 0); ?> <div dojoType='dijit.layout.AccordionContainer' region='center'> - <div dojoType='dijit.layout.AccordionPane' style='padding : 0' title='<i class="material-icons">report</i> <?= __('Event Log') ?>'> - <?php - if (Config::get(Config::LOG_DESTINATION) == "sql") { + <?php if (Config::get(Config::LOG_DESTINATION) == Logger::LOG_DEST_SQL) { ?> + <div dojoType='dijit.layout.AccordionPane' style='padding : 0' title='<i class="material-icons">report</i> <?= __('Event log') ?>'> + <?php $this->_log_viewer($page, $severity); - } else { - print_notice("Please set Config::get(Config::LOG_DESTINATION) to 'sql' in config.php to enable database logging."); - } - ?> + ?> + </div> + <?php } ?> + <div dojoType='dijit.layout.AccordionPane' style='padding : 0' title='<i class="material-icons">mail</i> <?= __('Mail configuration') ?>'> + <div dojoType="dijit.layout.ContentPane"> + + <form dojoType="dijit.form.Form"> + <script type="dojo/method" event="onSubmit" args="evt"> + evt.preventDefault(); + if (this.validate()) { + xhr.json("backend.php", this.getValues(), (reply) => { + const msg = App.byId("mail-test-result"); + + if (reply.rc) { + msg.innerHTML = __("Mail sent."); + msg.className = 'alert alert-success'; + } else { + msg.innerHTML = reply.error; + msg.className = 'alert alert-danger'; + } + + msg.show(); + }) + } + </script> + + <?= \Controls\hidden_tag("op", "pref-system") ?> + <?= \Controls\hidden_tag("method", "sendTestEmail") ?> + + <fieldset> + <label><?= __("To:") ?></label> + <?= \Controls\input_tag("mail_address", "", "text", ['required' => 1]) ?> + <?= \Controls\submit_tag(__("Send test email")) ?> + <span style="display: none; margin-left : 10px" class="alert alert-error" id="mail-test-result">...</span> + </fieldset> + </form> + </div> </div> - <div dojoType='dijit.layout.AccordionPane' title='<i class="material-icons">info</i> <?= __('PHP Information') ?>'> <script type='dojo/method' event='onSelected' args='evt'> if (this.domNode.querySelector('.loading')) |