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
    }

    }

  • 相关阅读:
    apt update ,apt upgrade 和 apt dist-upgrade 的区别
    CVE-2018-8639 简单利用 win7
    如何拆解性能测试需求
    博客搬家啦
    驱动开发学习一
    驱动开发基础之数据结构
    c++容器加迭代器和python装饰器的对比
    c++简单学习
    windows下z3安装
    switch反汇编
  • 原文地址:https://www.cnblogs.com/gride-glory/p/7989841.html
Copyright © 2011-2022 走看看