From 0730128a97a46054099b59554e891cee99829eaa Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 3 Mar 2021 14:00:18 +0300 Subject: [PATCH] add a send test email button to prefs/system --- classes/mailer.php | 13 +++++++---- classes/pluginhost.php | 2 +- classes/pref/system.php | 49 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/classes/mailer.php b/classes/mailer.php index 968caf54a..564338f69 100644 --- a/classes/mailer.php +++ b/classes/mailer.php @@ -1,8 +1,6 @@ set_error(error_get_last()['message']); + } + + return $rc; } function set_error($message) { $this->last_error = $message; + user_error("Error sending mail: $message", E_USER_WARNING); } function error() { diff --git a/classes/pluginhost.php b/classes/pluginhost.php index e96bbaa7c..bd0e9f4d8 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -61,7 +61,7 @@ class PluginHost { const HOOK_FEED_BASIC_INFO = "hook_feed_basic_info"; // hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed_id, $auth_login, $auth_pass) (byref) const HOOK_SEND_LOCAL_FILE = "hook_send_local_file"; // hook_send_local_file($filename) const HOOK_UNSUBSCRIBE_FEED = "hook_unsubscribe_feed"; // hook_unsubscribe_feed($feed_id, $owner_uid) - const HOOK_SEND_MAIL = "hook_send_mail"; // hook_send_mail($mailer, $params) + const HOOK_SEND_MAIL = "hook_send_mail"; // hook_send_mail(Mailer $mailer, $params) const HOOK_FILTER_TRIGGERED = "hook_filter_triggered"; // hook_filter_triggered($feed_id, $owner_uid, $article, $matched_filters, $matched_rules, $article_filters) const HOOK_GET_FULL_TEXT = "hook_get_full_text"; // hook_get_full_text($url) const HOOK_ARTICLE_IMAGE = "hook_article_image"; // hook_article_image($enclosures, $content, $site_url) diff --git a/classes/pref/system.php b/classes/pref/system.php index 85635e753..e58765c49 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(); @@ -161,6 +175,41 @@ class Pref_System extends Handler_Administrative { ?> +
'> +
+ +
+ + + + + +
+ + 1]) ?> + + +
+
+
+
'>