当前位置: 技术问答>java相关
用sun.net.smtp类发送EMAIL的一点问题
来源: 互联网 发布时间:2015-05-05
本文导语: package myservlet; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import sun.net.smtp.*; public class SmtpC extends HttpServlet { private static final String CONTENT_TYPE = "text/html;charset=gb2312"; private stati...
package myservlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import sun.net.smtp.*;
public class SmtpC extends HttpServlet {
private static final String CONTENT_TYPE = "text/html;charset=gb2312";
private static final String MAIL_FROM = "from";
private static final String MAIL_SUBJECT = "subject";
private static final String MAIL_BODY = "body";
private static final String MAIL_TO = "to";
private static final String MAIL_HOST = "host";
/**Initialize global variables*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**Process the HTTP Get request*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("");
out.println("SmtpC");
out.println("");
out.println("
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import sun.net.smtp.*;
public class SmtpC extends HttpServlet {
private static final String CONTENT_TYPE = "text/html;charset=gb2312";
private static final String MAIL_FROM = "from";
private static final String MAIL_SUBJECT = "subject";
private static final String MAIL_BODY = "body";
private static final String MAIL_TO = "to";
private static final String MAIL_HOST = "host";
/**Initialize global variables*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**Process the HTTP Get request*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("");
out.println("SmtpC");
out.println("");
out.println("