This module for Play! Framework 1 applications allows sending emails with Freemarker templating.
require:
- mail -> mail 1.3.0
repositories:
- sismicsNexusRaw:
type: http
artifact: "https://nexus.sismics.com/repository/sismics/[module]-[revision].zip"
contains:
- mail -> *
# Mail routes
* / module:mail
new Mailer();
Mailer.setFrom("[email protected]");
Mailer.setSubject("Subject");
Mailer.setBodyTemplate("db/email/welcome.ftl");
Mailer.addRecipient("[email protected]");
Mailer.send(ImmutableMap.of(
"base_url", Play.configuration.getProperty("application.baseUrl"),
"user_name", user.name)
);
Mailer.addAttachment(new InputStreamAttachement(is, "attachement.pdf", "application/pdf", "Attachement name"));
You can reuse messages defined in the play messages
file with the following command:
Mailer.setAddMessages(true);
Messages will be available in Freemarker templates under the key:
${messages['message.name']}
Use either / a combination of the following:
Mailer.setSubject("The Subject");
Mailer.setSubjectTemplate("db/email/subject.ftl");
Mailer.setSubjectText("Hello ${name}");
Mailer.setBody("The Body");
Mailer.setBodyTemplate("db/email/body.ftl");
Mailer.setBodyText("Click here: ${link}");
This software is released under the terms of the Apache License, Version 2.0. See LICENSE
for more
information or see https://opensource.org/licenses/Apache-2.0.