public static Result sendMail() { Mailer email = new Mailer(play.Play.application()); Map<String, String[]> formData = request().body().asFormUrlEncoded(); email.addFrom(utils.HttpUtil.getFirstValueFromQuery(formData, "from")); email.setSubject(utils.HttpUtil.getFirstValueFromQuery(formData, "subject")); email.addRecipient(utils.HttpUtil.getFirstValueFromQuery(formData, "to")); String errorMessage = null; boolean sended = false; try { email.send(utils.HttpUtil.getFirstValueFromQuery(formData, "body")); sended = true; } catch (EmailException e) { errorMessage = e.toString(); if (e.getCause() != null) { errorMessage += "<br/>Caused by: " + e.getCause(); } } return writeMail(errorMessage, sended); }