final String email = filledForm.get().email;
final Body body = new Body(
views.txt.email.body.render().toString(),
views.html.email.body.render().toString()
);
final Mailer defaultMailer = Mailer.getDefaultMailer();
{
// simple usage
defaultMailer.sendMail("play-easymail | it works!", body, email);
}
{
// advanced usage
final Mailer.Mail customMail = new Mailer.Mail("play-easymail | advanced", body, new String[]{ email });
customMail.addCustomHeader("Reply-To", email);
customMail.addAttachment(new Attachment("attachment.pdf", Play.application().getFile("conf/sample.pdf")));
byte[] data = "data".getBytes();
customMail.addAttachment(new Attachment("data.txt", data, "text/plain", "A simple file", EmailAttachment.INLINE));
defaultMailer.sendMail(customMail);
}
flash("message", "2 mails to '" + email + "' have been sent successfully!");
return redirect(routes.Application.index());
}