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 70dcdd1..a7309f9 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -395,6 +395,15 @@ def send_data(self): self.send_mail(msg=acknowledgement_mail, charset=charset) def prepare_message(self): + from bs4 import BeautifulSoup + + 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() and mail_header or None + mail_footer = BeautifulSoup(mail_footer).get_text() and mail_footer or None + email_format_page_template_mapping = { "list": "send_mail_template", "table": "send_mail_template_table", @@ -413,8 +422,8 @@ def prepare_message(self): "parameters": self.filter_parameters(), "url": self.context.absolute_url(), "title": self.context.Title(), - "mail_header": self.block.get("mail_header", {}).get('data', {}), - "mail_footer": self.block.get("mail_footer", {}).get('data', {}), + "mail_header": mail_header, + "mail_footer": mail_footer, } return message_template(**parameters)