/* * @(#)SendMailSurvey.java * * Copyright (c) 1998 Karl Moss. All Rights Reserved. * * You may study, use, modify, and distribute this software for any * purpose provided that this copyright notice appears in all copies. * * This software is provided WITHOUT WARRANTY either expressed or * implied. * * @author Karl Moss * @version 1.0 * @date 06Feb99 * */ package javaservlets.mail; import javax.servlet.*; import javax.servlet.http.*; import sun.net.smtp.*; /** *
This servlet will format an email form in HTML and, when * the user submits the form, will mail the message using * SMTP */ public class SendMailServlet extends HttpServlet { public static String MAIL_FROM = "from"; public static String MAIL_SUBJECT = "subject"; public static String MAIL_BODY = "body"; // Multiple 'to' addresses can be separated by commas public static String MAIL_TO = "karl@servletguru.com"; public static String MAIL_HOST = "server1.electronaut.com"; /** *
Performs the HTTP GET operation * * @param req The request from the client * @param resp The response from the servlet */ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { // Set the content type of the response resp.setContentType("text/html"); // Get the PrintWriter to write the response java.io.PrintWriter out = resp.getWriter(); // Create the HTML form out.println(""); out.println("
"); out.println("