Hello,
Can anyone please help me locate the template for the Mail action type in Form Container component?
I need to customize the template a bit by changing the wordings, etc.
Currently, the default email looks like this.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @pratikadobeaem, as far as I know this is not configurable - the email structure is hardcoded and can not be changed.
By default Mail action from Form Container component is handled by com.day.cq.wcm.foundation.forms.impl.MailServlet. In other words MailServlet combines all collected data from posted form and creates email object in the structure you could observe . Once email object is created it is sent using com.day.cq.mailer.MailService implementation.
The option I can see to address your case, is to create custom servlet that will be responsible to handle Mail action - this will give you full control related to email structure. It will also allow you to use some kind of template functionality to make it more flexible.
Hi @pratikadobeaem, as far as I know this is not configurable - the email structure is hardcoded and can not be changed.
By default Mail action from Form Container component is handled by com.day.cq.wcm.foundation.forms.impl.MailServlet. In other words MailServlet combines all collected data from posted form and creates email object in the structure you could observe . Once email object is created it is sent using com.day.cq.mailer.MailService implementation.
The option I can see to address your case, is to create custom servlet that will be responsible to handle Mail action - this will give you full control related to email structure. It will also allow you to use some kind of template functionality to make it more flexible.
Hi,
Email is configured vai Adobe CQ Form Mail Servlet service. and there is no template is used for this. The email content is hard coded in the code.
e.g.
SimpleEmail simpleEmail; StringBuilder builder = new StringBuilder(); builder.append(request.getScheme()); builder.append("://"); builder.append(request.getServerName()); if (request.getServerPort() >= 0 && (( request.getScheme().equals("https") && request.getServerPort() != 443) || (request .getScheme().equals("http") && request.getServerPort() != 80))) { builder.append(':'); builder.append(request.getServerPort()); } builder.append(request.getRequestURI()); StringBuilder buffer = new StringBuilder(); String text = resBundle.getString("You've received a new form based mail from {0}."); text = text.replace("{0}", builder.toString()); buffer.append(text); buffer.append("\n\n"); buffer.append(resBundle.getString("Values")); buffer.append(":\n\n"); List<String> contentNamesList = new ArrayList<>(); Iterator<String> names = FormsHelper.getContentRequestParameterNames(request); while (names.hasNext()) { String name = names.next(); contentNamesList.add(name); } Collections.sort(contentNamesList); List<String> namesList = new ArrayList<>(); Iterable<Resource> formElements = this.formStructureHelperFactory.getFormStructureHelper(formResource).getFormElements(formResource); for (Resource field : formElements) { FieldDescription[] descs = FieldHelper.getFieldDescriptions(request, field); for (FieldDescription desc : descs) { contentNamesList.remove(desc.getName()); if (!desc.isPrivate()) namesList.add(desc.getName()); } }
So we cannot modify the underlying logic?
Views
Replies
Total Likes
Views
Likes
Replies