From 13c5009e496091da8412ac7a5af542f102018c12 Mon Sep 17 00:00:00 2001
From: Thijs Kinkhorst <thijs@kinkhorst.com>
Date: Mon, 10 Jan 2022 10:43:17 +0000
Subject: [PATCH] Show what went wrong when sending the email.

Since this is an admin screen, we can show the exception message
unconditionally.
---
 modules/cron/lib/Controller/Cron.php        | 2 +-
 modules/cron/templates/croninfo-result.twig | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/cron/lib/Controller/Cron.php b/modules/cron/lib/Controller/Cron.php
index 114d2261e..42e1c6227 100644
--- a/modules/cron/lib/Controller/Cron.php
+++ b/modules/cron/lib/Controller/Cron.php
@@ -162,7 +162,7 @@ class Cron
             $t->data['time'] = $time;
             $t->data['url'] = $url;
             $t->data['mail_required'] = isset($mail);
-            $t->data['mail_sent'] = !isset($e);
+            $t->data['mail_exception'] = $e ?? null;
             $t->data['summary'] = $summary;
             return $t;
         }
diff --git a/modules/cron/templates/croninfo-result.twig b/modules/cron/templates/croninfo-result.twig
index eb755dd2e..ee61655d9 100644
--- a/modules/cron/templates/croninfo-result.twig
+++ b/modules/cron/templates/croninfo-result.twig
@@ -27,9 +27,11 @@ Tag: {{ tag }}
 </code>
 </div>
 
-{% if mail_required == true and mail_sent == false %}
+{% if mail_required == true and mail_exception %}
 <div class="message-box error">
-Cron-report was not emailed due to an error.
+Cron-report was not emailed due to an error:
+
+<pre>{{ mail_exception.getMessage() }}</pre>
 </div>
 {% endif %}
 {% endblock %}
-- 
GitLab