From c4dc6afc6942d4e1df2e9ce7c9f44bc96ea69ee1 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Mon, 2 May 2022 17:28:30 +0100
Subject: [PATCH] Enable logging of SMTP errors

---
 send-smtp-email.php | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/send-smtp-email.php b/send-smtp-email.php
index e67b588..e5d11ba 100644
--- a/send-smtp-email.php
+++ b/send-smtp-email.php
@@ -34,3 +34,11 @@ if (defined('SMTP_HOST')) {
 	}
 }
 
+/**
+ * Handler to log email failures.
+ */
+function log_mail_failure($wp_error) {
+    error_log('SMTP error: ' . print_r($wp_error, true));
+}
+
+add_action('wp_mail_failed', 'log_mail_failure', 10, 1);
-- 
GitLab