Hello Jonas,
Create a mail Template and Template Definition. You can look at some of the
existing examples under config->modules->mail.
Create a model class for the page or component containing your form. In the
model-class, implement the execute() method to check your form parameters, and
if the form was submitted correctly, send the mail.
The code for this could look something like this (in Magnolia 4.4, 4.5
shouldn't be too different):
public void sendEmail() throws Exception{
String recipient = NodeDataUtil.getString(getContent(),"orderEmail",null);
if (StringUtils.isEmpty(recipient))
throw new IllegalArgumentException("Film Bestellen: recipient is not set
in the publication. Set the recipient to send emails for this form.");
String subject =
NodeDataUtil.getString(getContent(),"orderEmailSubject",null);
MgnlMailFactory factory = MailModule.getInstance().getFactory();
Map<String, Object> params = new HashMap<String,Object>();
params.put("formModel", this);
if (!StringUtils.isEmpty(subject))
params.put("orderEmailSubject", subject);
params.put("film", content.getParent().getTitle());
MgnlEmail mail = factory.getEmailFromTemplate("filmBestellen", params);
if (!StringUtils.isEmpty(subject))
mail.setSubject(subject);
mail.setRecipient(RecipientType.TO, new InternetAddress(recipient));
InternetAddress[] addr = new InternetAddress[1];
addr[0] = new InternetAddress(getForm_email());
mail.setReplyTo(addr);
mail.setBodyFromResourceFile();
factory.getEmailHandler().sendMail(mail);
}
Regards from Vienna,
Richard
-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]]
Im Auftrag von Jonas Mende (via Magnolia Forums)
Gesendet: Freitag, 01. Februar 2013 14:59
An: Magnolia User List
Betreff: [magnolia-user] Use Magnolia Mail Module in Custom Form
Hi,
I am currently working on a project using Magnolia CE. I do not use any STK
Features.
I created a simple Form and would like to know how to make use of the Magnolia
Mail module in order to submit form entries via Mail.
I know that there is a Form Module as well, but since I do not use STK and this
module depends on STK, I would rather like to know how to use the mail module
itself. Does anybody know how to achieve this goal?
Many thanks in advance,
Jonas
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=257affa1-6b48-4453-ab67-55e92ce8f27e
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------