diff --git a/CHANGES.rst b/CHANGES.rst
index c385fe6..949796c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,9 +4,10 @@ Changelog
3.0.3 (unreleased)
------------------
+- Configurable header and footer for email message.
+ [folix-01]
- Subject templating
[folix-01]
-
- Handle the edge cases where the `blocks` attribute is not set.
[mamico]
diff --git a/pyproject.toml b/pyproject.toml
index 9af5bc4..e3f2e35 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -84,6 +84,7 @@ Zope = [
]
python-dateutil = ['dateutil']
'souper.plone' = ['souper', 'repoze.catalog']
+beautifulsoup4 = ['bs4']
# extra packages
ignore-packages = [
# these are packages defined in extras_require
diff --git a/setup.py b/setup.py
index e097ab4..0e1a9bb 100644
--- a/setup.py
+++ b/setup.py
@@ -68,6 +68,7 @@
"Products.PortalTransforms",
"souper.plone",
"click",
+ "beautifulsoup4",
"pyotp",
],
extras_require={
diff --git a/src/collective/volto/formsupport/browser/send_mail_template.pt b/src/collective/volto/formsupport/browser/send_mail_template.pt
index 0eb472b..1d17eff 100644
--- a/src/collective/volto/formsupport/browser/send_mail_template.pt
+++ b/src/collective/volto/formsupport/browser/send_mail_template.pt
@@ -3,9 +3,14 @@
parameters python:options.get('parameters', {});
url python:options.get('url', '');
title python:options.get('title', '');
+ mail_header python:options.get('mail_header', '');
+ mail_footer python:options.get('mail_footer', '');
"
i18n:domain="collective.volto.formsupport"
>
+
-
- A new form has been submitted from
- url
-
+
diff --git a/src/collective/volto/formsupport/browser/send_mail_template_table.pt b/src/collective/volto/formsupport/browser/send_mail_template_table.pt
index aac09cc..fc5fd2b 100644
--- a/src/collective/volto/formsupport/browser/send_mail_template_table.pt
+++ b/src/collective/volto/formsupport/browser/send_mail_template_table.pt
@@ -3,6 +3,8 @@
parameters python:options.get('parameters', {});
url python:options.get('url', '');
title python:options.get('title', '');
+ mail_header python:options.get('mail_header', '');
+ mail_footer python:options.get('mail_footer', '');
"
i18n:domain="collective.volto.formsupport"
>
@@ -11,8 +13,13 @@
text-align: start;
}
+
+
+
+ Form submission data for ${title}
+
+
- Form submission data for ${title}
|
+
diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py
index aed0727..5573359 100644
--- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py
+++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py
@@ -1,3 +1,4 @@
+from bs4 import BeautifulSoup
from collective.volto.formsupport import _
from collective.volto.formsupport.interfaces import ICaptchaSupport
from collective.volto.formsupport.interfaces import IFormDataStore
@@ -418,6 +419,14 @@ def send_data(self):
self.send_mail(msg=acknowledgement_mail, charset=charset)
def prepare_message(self):
+
+ mail_header = self.block.get("mail_header", {}).get("data", "")
+ mail_footer = self.block.get("mail_footer", {}).get("data", "")
+
+ # Check if there is content
+ mail_header = BeautifulSoup(mail_header).get_text() if mail_header else None
+ mail_footer = BeautifulSoup(mail_footer).get_text() if mail_footer else None
+
email_format_page_template_mapping = {
"list": "send_mail_template",
"table": "send_mail_template_table",
@@ -436,6 +445,8 @@ def prepare_message(self):
"parameters": self.filter_parameters(),
"url": self.context.absolute_url(),
"title": self.context.Title(),
+ "mail_header": mail_header,
+ "mail_footer": mail_footer,
}
return message_template(**parameters)