res.setContentType("text/plain");
PrintWriter out = res.getWriter();
ParameterParser parser = new ParameterParser(req);
String from = parser.getStringParameter("from", FROM);
String to = parser.getStringParameter("to", TO);
try {
MailMessage msg = new MailMessage(); // assume localhost
msg.from(from);
msg.to(to);
msg.setSubject("Customer feedback");
PrintStream body = msg.getPrintStream();
Enumeration enum = req.getParameterNames();
while (enum.hasMoreElements()) {
String name = (String)enum.nextElement();
if (name.equals("to") || name.equals("from")) continue; // Skip to/from
String value = parser.getStringParameter(name, null);
body.println(name + " = " + value);
}
body.println();
body.println("---");
body.println("Sent by " + HttpUtils.getRequestURL(req));
msg.sendAndClose();
out.println("Thanks for the submission...");
}
catch (IOException e) {
out.println("There was a problem handling the submission...");
log("There was a problem sending email", e);
}