From b750ff213962b6a47dd64945bcac4caea8e836c4 Mon Sep 17 00:00:00 2001
From: Dan Marsden <dan@danmarsden.com>
Date: Fri, 14 Jun 2019 14:02:13 +1200
Subject: [PATCH 1/1] MDL-60347 core: debugsmtp should be a developer only
 setting.

---
 lang/en/admin.php | 2 +-
 lib/moodlelib.php | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lang/en/admin.php b/lang/en/admin.php
index 26c89616de3..83790e7e08f 100644
--- a/lang/en/admin.php
+++ b/lang/en/admin.php
@@ -200,7 +200,7 @@ $string['configdbsessions'] = 'If enabled, this setting will use the database to
 $string['configdebug'] = 'If you turn this on, then PHP\'s error_reporting will be increased so that more warnings are printed.  This is only useful for developers.';
 $string['configdebugdisplay'] = 'Set to on, the error reporting will go to the HTML page. This is practical, but breaks XHTML, JS, cookies and HTTP headers in general. Set to off, it will send the output to your server logs, allowing better debugging. The PHP setting error_log controls which log this goes to.';
 $string['configdebugpageinfo'] = 'Enable if you want page information printed in page footer.';
-$string['configdebugsmtp'] = 'Enable verbose debug information during sending of email messages to SMTP server.';
+$string['configdebugsmtp'] = 'Enable verbose debug information during sending of email messages to SMTP server. For this setting to take effect, the \'Debug messages\' setting must be set to \'Developer\'.';
 $string['configdebugvalidators'] = 'Enable if you want to have links to external validator servers in page footer. You may need to create new user with username <em>w3cvalidator</em>, and enable guest access. These changes may allow unauthorized access to server, do not enable on production sites!';
 $string['configdefaulthomepage'] = 'This determines the home page for logged in users';
 $string['configdefaultrequestcategory'] = 'Courses requested by users will be automatically placed in this category.';
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 820dc475545..e5ffe1dfd15 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -5762,7 +5762,7 @@ function get_mailer($action='get') {
         } else {
             // Use SMTP directly.
             $mailer->isSMTP();
-            if (!empty($CFG->debugsmtp)) {
+            if (!empty($CFG->debugsmtp) && (!empty($CFG->debugdeveloper))) {
                 $mailer->SMTPDebug = 3;
             }
             // Specify main and backup servers.
-- 
2.17.1

