From 4286da9ebffbcac8339971cb346b0758077db122 Mon Sep 17 00:00:00 2001
From: Torsten Oppermann <torsten@sgalinski.de>
Date: Mon, 10 Sep 2018 17:50:02 +0200
Subject: [PATCH] [TASK] Add possibility to add a fallback html template

---
 Classes/Service/MailTemplateService.php | 8 +++++++-
 Configuration/TypoScript/setup.ts       | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php
index 4db953ed..cca1d500 100644
--- a/Classes/Service/MailTemplateService.php
+++ b/Classes/Service/MailTemplateService.php
@@ -301,7 +301,13 @@ class MailTemplateService {
 					$defaultTemplateContent = self::getRegisterArray(
 					)[$this->extensionKey][$this->templateName]['templateContent'];
 				} else {
-					return FALSE;
+
+					$defaultTemplateFile = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultHtmlTemplate'];
+					if (file_exists($defaultTemplateFile)) {
+						$defaultTemplateContent = file_get_contents($defaultTemplateFile);
+					} else {
+						return FALSE;
+					}
 				}
 			}
 		} elseif (filter_var($template->getToAddress(), FILTER_VALIDATE_EMAIL)) {
diff --git a/Configuration/TypoScript/setup.ts b/Configuration/TypoScript/setup.ts
index 984ce06f..132d43f3 100644
--- a/Configuration/TypoScript/setup.ts
+++ b/Configuration/TypoScript/setup.ts
@@ -18,6 +18,9 @@ module.tx_sgmail {
 
 			# extension where automatic generated registrations from forms are put. gets appended with /Configuration/MailTemplates/. make sure these folders exist!
 			configurationLocation = project_theme
+
+			# default html template file, which serves as a fallback for all mail templates
+			defaultHtmlTemplate = EXT:project_theme/Configuration/MailTemplates/Default.html
 		}
 
 		# default template language
-- 
GitLab