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 {
SmtpClient smtp = new SmtpClient(); // assume localhost
smtp.from(from);
smtp.to(to);
PrintStream msg = smtp.startMessage();
msg.println("To: " + to); // so mailers will display the To: address
msg.println("Subject: Customer feedback");
msg.println();
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);
msg.println(name + " = " + value);
}
msg.println();
msg.println("---");
msg.println("Sent by " + HttpUtils.getRequestURL(req));
smtp.closeServer();
out.println("Thanks for the submission...");
}
catch (IOException e) {
out.println("There was a problem handling the submission...");
getServletContext().log(e, "There was a problem sending email");
}