zoukankan      html  css  js  c++  java
  • commons-email

    package dbc;

    import java.io.IOException;
    import java.io.PrintWriter;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.apache.commons.mail.EmailException;
    import org.apache.commons.mail.SimpleEmail;

    public class SendMail extends HttpServlet {

    /**
    * Constructor of the object.
    */
    public SendMail() {
    super();
    }
    public void destroy() {
    super.destroy(); // Just puts "destroy" string in log
    // Put your code here
    }
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doPost(request,response);
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    response.setContentType("text/html;charset=utf-8");
    PrintWriter out = response.getWriter();
    request.setCharacterEncoding("utf-8");
    SimpleEmail email= new SimpleEmail();
    email.setHostName("smtp.qq.com");
    email.setAuthentication("1103243851","wuyiming980719");
    System.out.println("heree");
    try{
    email.addTo(request.getParameter("to"));//收件人
    email.setFrom("1103243851@qq.com");
    email.setSubject(request.getParameter("title"));//邮件主题
    email.setMsg(request.getParameter("content"));
    email.send();
    out.print("success");
    }catch(EmailException e) {
    e.printStackTrace();
    out.print("failed");
    }
    }

    /**
    * Initialization of the servlet. <br>
    *
    * @throws ServletException if an error occurs
    */
    public void init() throws ServletException {
    // Put your code here
    }

    }

  • 相关阅读:
    计算公式以及参数数量计算
    sqlmap查找SQL注入漏洞入门
    动态密码卡TOTP算法
    使用windbg分析iis崩溃的一个实例
    windbg加载sos.dll
    wndbg下载与安装
    windbg入门
    IIS崩溃时自动抓取Dump
    net组件转化成COM组件
    dokuwiki安装部署
  • 原文地址:https://www.cnblogs.com/gride-glory/p/7989841.html
Copyright © 2011-2022 走看看