use of com.usthe.manager.support.exception.AlertNoticeException in project hertzbeat by dromara.
the class EmailAlertNotifyHandlerImpl method send.
@Override
public void send(NoticeReceiver receiver, Alert alert) {
try {
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
messageHelper.setSubject("TanCloud探云-监控告警");
// Set sender Email 设置发件人Email
messageHelper.setFrom(emailFromUser);
// Set recipient Email 设定收件人Email
messageHelper.setTo(receiver.getEmail());
messageHelper.setSentDate(new Date());
// Build email templates 构建邮件模版
String process = mailService.buildAlertHtmlTemplate(alert);
// Set Email Content Template 设置邮件内容模版
messageHelper.setText(process, true);
javaMailSender.send(mimeMessage);
} catch (Exception e) {
log.error("[Email Alert] Exception,Exception information={}", e.getMessage());
throw new AlertNoticeException("[Email Alert] failed: " + e.getMessage());
}
}
Aggregations