Expand my Community achievements bar.

Nomination window for the Adobe Community Advisor Program, Class of 2025, is now open!

How to send an email to an address submitted via form in a component?

Avatar

Level 2

In this form I have text inputs and an email field. The intention is to send the results of these fields to the email written in the form when you press the send button.

3 Replies

Avatar

Level 5

Hi @Vodjakxa 

Create a servlet to handle the form data processing. The servlet will:

  1. Extract the submitted input data from the form.
  2. Use the email address entered in the form as the recipient.
  3. Send an email containing the form details.

This approach is explained in detail in this blog, which provides guidance on sending emails upon form submission.

https://medium.com/@toimrank/aem-email-custom-template-style-and-attachment-d4c0a196ec98

 

Regards

Ayush

Avatar

Level 2

Thanks for the reply.

I was looking for a simpler and more immediate method, without having to create new dependencies, but possibly a function already integrated with AEM.

Avatar

Level 6

To send an email via a form in AEM:
1. Create a Servlet to handle the form submission and send the email:
        - Capture form data (like email, subject, message).
        - Use Day CQ Mail Service to send the email. Form HTML (example):

2.Form HTML (example):

<form action="/bin/send-email" method="post">
    <input type="email" name="email" placeholder="Recipient Email" required />
    <input type="text" name="subject" placeholder="Subject" required />
    <textarea name="message" placeholder="Message" required></textarea>
    <button type="submit">Send</button>
</form>

3. Configure SMTP settings in AEM for email sending.

4. Test the form submission