From 1686ee33d3e646813173a486bf4077c6bcb58d04 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 23 Dec 2019 17:53:46 +0000 Subject: [PATCH] Add new email_debug_dontsend setting --- Changelog.md | 1 + core/05-functions.php | 14 +++++++++++++- peppermint.guiconfig.json | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index bf44e96..d074ada 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t - Fixed link loop when logging in for crawlers - [security] Bugfix: Don't leak the PHP version in emails when expose_php is turned off - Fixed handling of Unicode characters when emailing users - added new `email_subject_utf8` and `email_body_utf8` settings to control the new behaviour + - Add new `email_debug_dontsend` setting for debugging emails sent by Pepperminty Wiki ## Changed - Improved the search indexing system performance - again diff --git a/core/05-functions.php b/core/05-functions.php index cce95d2..f8c3d71 100644 --- a/core/05-functions.php +++ b/core/05-functions.php @@ -730,7 +730,19 @@ function email_user($username, $subject, $body) foreach($headers as $header => $value) $compiled_headers .= "$header: $value\r\n"; - return mail($settings->users->{$username}->emailAddress, $subject, $body, $compiled_headers, "-t"); + if($settings->email_debug_dontsend) { + error_log("[email] Username: $username ({$settings->users->{$username}->emailAddress}) +Subject: $subject +----- Headers ----- +$compiled_headers +------------------- +----- Body ----- +$body +----------------"); + return true; + } + else + return mail($settings->users->{$username}->emailAddress, $subject, $body, $compiled_headers, "-t"); } /** * Sends a plain text email to a list of users, replacing {username} with each user's name. diff --git a/peppermint.guiconfig.json b/peppermint.guiconfig.json index f2a7cac..d77ba2a 100644 --- a/peppermint.guiconfig.json +++ b/peppermint.guiconfig.json @@ -228,6 +228,7 @@ "search_tags_matches_weighting": { "type": "number", "description": "The weighting to give to search term matches found in a page's tags.", "default": 3}, "dynamic_page_suggestion_count": { "type": "number", "description": "The number of dynamic page name suggestions to fetch from the server when typing in the page search box. Note that lowering this number doesn't really improve performance. Set to 0 to disable.", "default": 7 }, "defaultaction": { "type": "text", "description": "The default action. This action will be performed if no other action is specified. It is recommended you set this to \"view\" - that way the user automatically views the default page (see above).", "default": "view" }, + "email_debug_dontsend": { "type": "checkbox", "description": "If set to true, emails are logged to the standard error instead of being actually sent.", "default": false }, "email_subject_utf8": { "type": "checkbox", "description": "Whether to encode the subject of emails sent to allow them to contain unicode characters. Without this, email subjects will be transliterated to ASCII. If utf-8 email subjects are disabled, page names may not be represented properly.", "default": true }, "email_body_utf8": { "type": "checkbox", "description": "Whether to send emails with utf-8 bodies. If set to false, email bodies will be transliterated to ASCII. If utf-8 email bodies are disabled, page names may not be represented properly.", "default": true }, "updateurl": { "type": "url", "description": "The url from which to fetch updates. Defaults to the master (development) branch. MAKE SURE THAT THIS POINTS TO A *HTTPS* URL, OTHERWISE SOMEONE COULD INJECT A VIRUS INTO YOUR WIKI!", "default": "https://raw.githubusercontent.com/sbrl/pepperminty-wiki/master/index.php" },