AEM Core Forms Container | Community
Skip to main content
March 30, 2023
Solved

AEM Core Forms Container

  • March 30, 2023
  • 1 reply
  • 1274 views

When using the ootb core forms container and action type as "Mail" I am able to send the email from AEM but I would like to create my own custom email template for my use case. Can anybody point me at email template I would need to override or which template Forms Container uses to send the emails inside AEM. I know we can create our own email service and have custom template but I am more curious to know if we can override ootb email template.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JeevanRaj

The email body is built in com.day.cq.wcm.foundation.forms.impl.MailServlet. You cannot just override the template here, you need to create your own custom servlet for the "Mail" action.

 

To create your custom servlet for mail action,

  1. Override foundation/components/form/actions/mail/forward.jsp
  2. Override this line and add a selector(XYZ)
    FormsHelper.setForwardPath(slingRequest, resource.getPath() + ".XYZ.html");
  3. Create your own MailServlet
    @Component(service = Servlet.class,
    property = {
    "sling.servlet.resourceTypes=" + "foundation/components/form/start",
    "sling.servlet.resourceTypes=" + "core/wcm/components/form/container/v2/container",
    "sling.servlet.methods=" + "POST",
    "sling.servlet.selectors=" + "XYZ",
    "service.description=" + "Form Mail Servlet"
    })
    This thread might help you. Do let me know if you have further queries.

1 reply

JeevanRaj
Community Advisor
JeevanRajCommunity AdvisorAccepted solution
Community Advisor
March 31, 2023

The email body is built in com.day.cq.wcm.foundation.forms.impl.MailServlet. You cannot just override the template here, you need to create your own custom servlet for the "Mail" action.

 

To create your custom servlet for mail action,

  1. Override foundation/components/form/actions/mail/forward.jsp
  2. Override this line and add a selector(XYZ)
    FormsHelper.setForwardPath(slingRequest, resource.getPath() + ".XYZ.html");
  3. Create your own MailServlet
    @Component(service = Servlet.class,
    property = {
    "sling.servlet.resourceTypes=" + "foundation/components/form/start",
    "sling.servlet.resourceTypes=" + "core/wcm/components/form/container/v2/container",
    "sling.servlet.methods=" + "POST",
    "sling.servlet.selectors=" + "XYZ",
    "service.description=" + "Form Mail Servlet"
    })
    This thread might help you. Do let me know if you have further queries.
May 6, 2024

Is it still working for AEMaaCS? With overlayed forward.jsp I can see 302 redirect in browser but without selector defined so my servlet is not triggering.

JeevanRaj
Community Advisor
Community Advisor
May 6, 2024

I haven't tried this in AEMaaCS. Works with AEM 6.5.