Esempio n. 1
0
 public static void mail() throws EmailException {
   SimpleEmail email = new SimpleEmail();
   email.setFrom("*****@*****.**");
   email.addTo("*****@*****.**");
   email.setSubject("メールのテスト");
   email.setMsg("メールの本文です。本文です。");
   email.setContent("メールの本文です。本文です。", "text/plain; charset=ISO-2022-JP");
   email.setCharset("ISO-2022-JP");
   Mail.send(email);
 }
Esempio n. 2
0
 /**
  * @param username 用户名
  * @param ip 用户登录时的Ip
  * @param time 用户登录的时间
  */
 public void sendEmail(String username, String ip, String time) {
   SimpleEmail simpleEmail = new SimpleEmail();
   simpleEmail.setAuthentication("*****@*****.**", "Q2889144");
   simpleEmail.setHostName("smtp.126.com");
   simpleEmail.setSmtpPort(25);
   simpleEmail.setCharset("utf-8");
   try {
     simpleEmail.setFrom("*****@*****.**");
     simpleEmail.addTo("*****@*****.**");
     simpleEmail.setMsg(time + ",用户:" + username + "在" + ip + "登录");
     simpleEmail.setSubject("开会");
     simpleEmail.send();
   } catch (EmailException e) {
     e.printStackTrace();
   }
 }
Esempio n. 3
0
  /**
   * 메일을 발송한다.
   *
   * <p>when 메일발송 페이지에서 발송시
   *
   * <p>입력폼으로부터 보내는 메일주소, 받는사람 제목, 본문내용을 입력받고 {@code email} 객체에 할당한다. 메일을 발송하고 결과를 {@code sended}에
   * 할당한다. {@code writeMail()} 을 통해 메일 전송여부와 오류메세지를 설정하고 메일발송 페이지로 이동한다.
   *
   * @return the result
   * @throws EmailException the email exception
   * @see {@link SiteApp#writeMail(String, boolean)}
   */
  public static Result sendMail() throws EmailException {
    SimpleEmail email = new SimpleEmail();

    Map<String, String[]> formData = request().body().asFormUrlEncoded();
    email.setFrom(utils.HttpUtil.getFirstValueFromQuery(formData, "from"));
    email.setSubject(utils.HttpUtil.getFirstValueFromQuery(formData, "subject"));
    email.addTo(utils.HttpUtil.getFirstValueFromQuery(formData, "to"));
    email.setMsg(utils.HttpUtil.getFirstValueFromQuery(formData, "body"));
    email.setCharset("utf-8");

    String errorMessage = null;
    boolean sended;
    String result = Mailer.send(email);
    Logger.info(">>>" + result);
    sended = true;
    return writeMail(errorMessage, sended);
  }
Esempio n. 4
0
  public void send() {
    SimpleEmail email = new SimpleEmail();
    email.setTLS(TLS); // 是否TLS校验,,某些邮箱需要TLS安全校验,同理有SSL校验
    email.setHostName(hostName);
    try {
      email.setFrom(sendMailAddress, sendMailAddress);
      email.setAuthentication(sendMailAddress, mailPassword);
      email.setCharset("utf-8"); // 解决中文乱码问题
      email.setSubject(mailTitle); // 标题
      email.setMsg(mailContent); // 内容
      for (int i = 0; i < getMailAddress.length; ++i) {
        email.addTo(getMailAddress[i]); // 接收方
        email.send();
      }

    } catch (EmailException e) {
      //  e.printStackTrace();
    }
  }