Ejemplo n.º 1
0
  /** @参数名:@param subject 邮件主题 @参数名:@param content 邮件主题内容 @参数名:@param to 收件人Email地址 */
  public static void send(String subject, String content, String to) {
    ClassPathXmlApplicationContext context =
        new ClassPathXmlApplicationContext("spring-smtp-mail.xml");

    Email mm = (Email) context.getBean("simpleMail");
    try {
      LOGGER.info(
          "Params : createTime = ["
              + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date())
              + "] ,  subject = ["
              + subject
              + "] ,  content = ["
              + content
              + "] ,  to = ["
              + to
              + "]");
      mm.sendMail(subject, content, to);
      context.close();
    } catch (MessagingException e) {
      LOGGER.info("context", e);
    }
  }