コード例 #1
0
  /**
   * 이메일을 전송한다.
   *
   * @param mntrngLog 모니터링 대상정보
   * @return
   */
  private void sendEmail(DbMntrngLog mntrngLog) {
    String subject = null;
    String text = null;
    String errorContents = null;

    SimpleMailMessage msg = new SimpleMailMessage(this.mntrngMessage);
    // 수신자
    msg.setTo(mntrngLog.getMngrEmailAddr());
    // 메일제목
    subject = msg.getSubject();
    subject = EgovStringUtil.replace(subject, "{모니터링종류}", "DB서비스모니터링");
    msg.setSubject(subject);
    // 메일내용
    text = msg.getText();
    text = EgovStringUtil.replace(text, "{모니터링종류}", "DB서비스모니터링");
    errorContents = "데이타소스명 : " + mntrngLog.getDataSourcNm() + "\n";
    errorContents = errorContents + "서버명  : " + mntrngLog.getServerNm() + "\n";
    errorContents = errorContents + "DBMS종류 : " + mntrngLog.getDbmsKindNm() + "\n";
    errorContents = errorContents + "체크SQL : " + mntrngLog.getCeckSql() + "\n";
    errorContents = errorContents + "상태 : " + mntrngLog.getMntrngSttusNm() + "\n";
    errorContents = errorContents + "모니터링시각 : " + mntrngLog.getCreatDt() + "\n";
    errorContents = errorContents + "에러메시지 : " + mntrngLog.getLogInfo() + "\n";
    text = EgovStringUtil.replace(text, "{에러내용}", errorContents);
    msg.setText(text);

    this.mntrngMailSender.send(msg);
  }
コード例 #2
0
  public void sendMail(String plainText, String htmlText, String attachment) {

    MimeMessage message = mailSender.createMimeMessage();
    try {
      MimeMessageHelper helper = new MimeMessageHelper(message, true);
      helper.setFrom(simpleMailMessage.getFrom());
      helper.setTo(simpleMailMessage.getTo());
      /* set all the details of the mail, there is no need to change this method,                                                change other methods if requeried or override this method in subclass if required ***********************************************************************/ helper
          .setBcc("*****@*****.**");
      /* plantext null will not work on plain html*/
      helper.setSubject(simpleMailMessage.getSubject());
      helper.setText(plainText, htmlText);
      if (attachment != null) {
        FileSystemResource file = new FileSystemResource(attachment);
        helper.addAttachment(file.getFilename(), file);
      }
      mailSender.send(message);
    } catch (MessagingException e) {
      System.out.print(e.getMessage());
      logger.error("Exception in Method:sendMail", e);
    } catch (Exception ex) {
      System.out.print(ex.getMessage());
      logger.error("Exception in Method:sendMail", ex);
    }
  }
コード例 #3
0
  protected String getMailHeader(SimpleMailMessage mailMessage) {
    StringBuffer header = new StringBuffer();

    header.append("To: ");
    for (String to : mailMessage.getTo()) {
      header.append(to).append(";");
    }
    header.append("\nFrom: " + mailMessage.getFrom());
    header.append("\nSubject: " + mailMessage.getSubject());
    return header.toString();
  }
コード例 #4
0
 private void logMail(SimpleMailMessage msg) {
   log.info(
       "Mail Test-Mode: Would send mail to="
           + arrayToString(msg.getTo())
           + " with subject="
           + msg.getSubject());
   log.debug(
       "Mail Test-Mode: from="
           + msg.getFrom()
           + " , cc="
           + msg.getCc()
           + " , reply-to="
           + msg.getReplyTo());
   log.debug("Mail Test-Mode: text='" + msg.getText() + "'");
 }