Send email via FORM in CQ5
Hi,
I'm trying to send e-mail with some information provided via <form> but I'm not really sure how to do it. I've understood that I need to create Servlet that process the form data and sends the email. I've tried to follow these instructions but it's not clear enough for CQ5/Servlet(I don't have any experience with Servlets) newbie like me. I've successfully created the component(I already have some experiences with components) and bundle under /apps/myapp/src but I don't know what to do next and where to put all the code. I'm getting confused in the "Creating the HTML Email Servlet" part. Where should I put that code there? Into my component or into the Servlet? I think I should put this
String template = properties.get("emailTemplate","/notset"); Resource templateRsrc = request.getResourceResolver().getResource(template); if (templateRsrc.getChild("file") != null) { templateRsrc = templateRsrc.getChild("file"); } if (templateRsrc == null) { throw new IllegalArgumentException("Missing template: " + template); } final MailTemplate mailTemplate = MailTemplate.create(templateRsrc.getPath(), templateRsrc.getResourceResolver().adaptTo(Session.class)); final HtmlEmail email = mailTemplate.getEmail(StrLookup.mapLookup(properties), HtmlEmail.class);to the component code but how do I pass all the info to the servlet after the user submits the form?
So basically I need to get data from html form(created with my component) and then send it to some e-mail. Can you help me? Some commented working code will be enough, I can program in Java so I can edit it to my needs.
BTW I the mailing settings in OSGi are already properly set.
Thanks for any help and sorry for my poor english and poor description of the problem.