Hi @wizard04wsu,
Adobe CQ Form Mail Servlet handles the Mail Action type of Form Container (see implementation in the com.day.cq.wcm.foundation.forms.impl.MailServlet).
Based on its implementation, it can send 2 types of emails:
- Multi-part email when attachments more than 1: org.apache.commons.mail.MultiPartEmail
- Simple email: org.apache.commons.mail.SimpleEmail
To send an HTML email, you need to use org.apache.commons.mail.HtmlEmail.
There is a good AEM Email API provided by ACS Commons: https://adobe-consulting-services.github.io/acs-aem-commons/features/e-mail/email-api/index.html. It allows you to use different email templates persisted in the repository, to send attachments etc.
I see 2 options for you:
- create project-specific form action implementation (foundation/components/form/action). There are examples: /libs/foundation/components/form/actions/mail, /apps/core/wcm/components/form/actions/rpc. You will need to register a new servlet where you will use ACS Commons Email service,
- override the default Mail servlet by registering a custom MailServlet with the same declaration as com.day.cq.wcm.foundation.forms.impl.MailServlet but with a higher service ranking. In it, you can use ACS Commons Email Service.
I would suggest implementing option 1 because it won't affect OOTB code and will work separately.