SMTP(Simple Mail Transfer Protocol)
* SMTP๋?
๐Simple Mail Transfer Protocol์ ์ฝ์๋ก ์ ์ ๋ฉ์ผ ์ ์ก์ ์ํ ํ์ค ํ๋กํ ์ฝ์ด๋ค.
(์ด๋ฉ์ผ์ ์ก์์ ํ๋ ์๋ฒ๋ฅผ SMTP ์๋ฒ๋ผ๊ณ ํ๋ค)
* ์๋๋ฐฉ์์?
์ด๋ฉ์ผ ํด๋ผ์ด์ธํธ์ ๋ฉ์ผ ์๋ฒ ๊ฐ์ ๋ฐ์ดํฐ ๊ตํ ํ๋ก์ธ์ค๋ฅผ ๊ฑฐ์ณ ๋์ํ๋ค.
- SMTP ์ฐ๊ฒฐ: ํด๋ผ์ด์ธํธ์ ์๋ฒ ๊ฐ TCP ์ฐ๊ฒฐ๋ก ์ด๋ฉ์ผ ์ ์ก ํ๋ก์ธ์ค๋ฅผ ์์
- ์ด๋ฉ์ผ ๋ฐ์ดํฐ ์ ์ก: ํด๋ผ์ด์ธํธ๊ฐ ์ด๋ฉ์ผ ํค๋(๋์ ๋ฐ ์ ๋ชฉ ์ค ํฌํจ), ์ด๋ฉ์ผ ๋ณธ๋ฌธ, ๊ธฐํ ์ถ๊ฐ ๊ตฌ์ฑ ์์๋ก ์ด๋ฃจ์ด์ง ์ค์ ์ด๋ฉ์ผ ์ฝํ ์ธ ์ ํจ๊ป ์ผ๋ จ์ ๋ช ๋ น์ ์๋ฒ์ ๋ณด๋
- ๋ฉ์ผ ์ ์ก ์์ด์ ํธ(MTA): MTA๋ ์์ ์์ ์ด๋ฉ์ผ ์ฃผ์ ๋๋ฉ์ธ์ ํ์ธํ๊ณ ๋ฐ์ ์์ ๋ค๋ฅผ ๊ฒฝ์ฐ ์์ ์์ IP์ฃผ์๋ฅผ ์ฐพ๋๋ก ๋๋ฉ์ธ ๋ค์ ์์คํ (DNS)์ ์ฟผ๋ฆฌํ๋ค. (์ฐ์ฒด๊ตญ์์ ์ฐํธ๋ฌผ ์์ ์์ ์ฐํธ๋ฒํธ๋ฅผ ์กฐํํ๋ ๊ฒ๊ณผ ๊ฐ๋ค.)
- ์ฐ๊ฒฐ ์ข ๋ฃ: ๋ฐ์ดํฐ ์ ์ก์ด ์๋ฃ๋๋ฉด ํด๋ผ์ด์ธํธ๊ฐ ์๋ฒ์ ์๋ฆผ์ ๋ณด๋ด๋ฉฐ ์๋ฒ๊ฐ ์ฐ๊ฒฐ์ ๋ซ๋๋ค.
- (์ด๋ ํด๋ผ์ด์ธํธ๊ฐ SMTP ์ฐ๊ฒฐ์ ์๋ก ์ด์ง ์๋ ํ ์๋ฒ๋ ํด๋ผ์ด์ธํธ๋ก๋ถํฐ ์ด๋ฉ์ผ ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐ๋ก ๋ฐ์ง ์๋๋ค.)
* ์ฝ๋ ๊ตฌํ
public static void smtp(AlertModel alertModel) throws MessagingException, UnsupportedEncodingException {
final String user = "blabla@gmail.com"; //๋ฐ์ ๋ฉ์ผ (์ด ์ฌ๋ ๊ณ์ ์ผ๋ก ๋ณด๋ด๊ฒ ๋ค.)
final String name = "[SMTP ๋ฉ์ผ ์ ์ก]";
final String password = "abcdefg1234"; //์ํธํ๋ ๋น๋ฐ๋ฒํธ ํค
final String port = "587";
final String bodyEncoding = "UTF-8"; //์ฝํ
์ธ ์ธ์ฝ๋ฉ
// SMTP ์๋ฒ ์ ๋ณด๋ฅผ ์ค์ ํ๋ค.
Properties prop = new Properties();
prop.put("mail.smtp.host", "smtp.gmail.com");
prop.put("mail.smtp.port", port);
prop.put("mail.smtp.auth", "true");
prop.put("mail.smtp.ssl.trust", "smtp.gmail.com");
prop.put("mail.smtp.starttls.enable", "true");
prop.put("mail.smtp.ssl.protocols", "TLSv1.2");
Session session = Session.getDefaultInstance(prop, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
});
//๋ฉ์์ง ํฌ๋งท์ ๋ด๊ธฐ์ํด ์์ฑ
MimeMessage message = new MimeMessage(session);
// ๋ฉ์ผ ์ฝํ
์ธ ์ค์
Multipart mParts = new MimeMultipart();
MimeBodyPart mTextPart = new MimeBodyPart();
//์ด๋ฉ์ผ ํค๋ ์ค์
message.setHeader("content-Type", "text/html");
//๋ฐ์ ์ ์ค์
message.setFrom(new InternetAddress(user, name, bodyEncoding));
// MIME ํ์
์ค์
MailcapCommandMap MailcapCmdMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
MailcapCmdMap.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
MailcapCmdMap.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
MailcapCmdMap.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
MailcapCmdMap.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
MailcapCmdMap.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(MailcapCmdMap);
//TODO: ์์ ์ ๋ฉ์ผ
InternetAddress[] toSales = {
new InternetAddress("sales@company.com"),
new InternetAddress("support@company.com"),
new InternetAddress("dmshin@company.com"),
new InternetAddress("ljy@company.com"),
};
InternetAddress[] toSupport = {
new InternetAddress("heo@company.com"),
new InternetAddress("cs@company.com"),
new InternetAddress("csb@company.com"),
new InternetAddress("karstar@company.com"),
new InternetAddress("joomsm@company.com"),
};
InternetAddress[] toCs = {
new InternetAddress("jjh@company.com"),
new InternetAddress("lhj@company.com"),
new InternetAddress("shr@company.com"),
new InternetAddress("ysy@company.com"),
new InternetAddress("min@company.com"),
new InternetAddress("sjcho@company.com"),
};
InternetAddress[] toSystem = {
new InternetAddress("system@company.com"),
};
InternetAddress[] toTarget = {new InternetAddress(alertModel.getReceiver() + "@company.com")};
StringBuffer sb = new StringBuffer();
//๋ฉ์์ง ์์ธ์ฒ๋ฆฌ
try {
message.setSubject("โป์์คํ
์๋์๋ฆผ[" + alertModel.getService() + "] " + alertModel.getTitle()); //๋ฉ์ผ ์ ๋ชฉ์ ์
๋ ฅ
//NOTE: Table Start
sb.append("<div style=\"width: 70%; margin:0 auto\">" +
" <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" +
" style=\"max-width:100%;width:100%;font-family:'๋๋๊ณ ๋',NanumGothic,'๋ง์๊ณ ๋',Malgun Gothic,'๋์',Dotum,Helvetica,'Apple SD Gothic Neo',Sans-serif;background-color:#fff;-webkit-text-size-adjust:100%;text-align:left\">" +
" <!-- Header -->" +
" <tbody>");
//NOTE: Header
sb.append("<tr>" +
" <td height=\"30\"></td>" +
" </tr>" +
" <tr>" +
" <td style=\"padding-right:27px; padding-left:21px\">" +
" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" +
" <tbody>" +
" <tr>" +
" <td style=\"\" width=\"61\"><img" +
" src=\"https://company.com/img/logo2.png\" alt=\"UBCn\"" +
" width=\"61\" loading=\"lazy\"></td>" +
" </tr>" +
" </tbody>" +
" </table>" +
" </td>" +
" </tr>" +
" <tr>" +
" <td height=\"13\"></td>" +
" </tr>" +
" <tr>" +
" <td style=\"padding-right:27px; padding-left:18px;line-height:34px;font-size:29px;color:#424240;font-family:'๋๋๊ณ ๋',NanumGothic,'๋ง์๊ณ ๋',Malgun Gothic,'๋์',Dotum,Helvetica,'Apple SD Gothic Neo',Sans-serif;\">" +
" ๋ฐฐ์น ์์คํ
์์ ๋ฐ์กํ๋<br><span style=\"color:#1ec800\">์๋์๋ฆผ ์
๋๋ค.</span></td>" +
" </tr>" +
" <tr>" +
" <td height=\"22\"></td>" +
" </tr>" +
" <tr>" +
" <td height=\"1\" style=\"background-color: #e5e5e5;\"></td>" +
" </tr> <!-- //Header -->");
//์ด๋ฉ์ผ ํ์ ๊ตฌ๋ฌธ
if (alertModel.getService().equalsIgnoreCase("QNA")) {
alertModel.setTitle("[๋ฌธ์ํ๊ธฐ] ํํ์ด์ง์ ์ ์ฒญ(๋ฌธ์)ํผ์ด ์ ์๋์์ต๋๋ค.");
//NOTE: Content Table Header
sb.append(Convenience.StringUtils.contentTableHeader());
//NOTE: Content Table
sb.append(
Convenience.StringUtils.contentTableRow("์๊ฐ", alertModel.getSendDate()) +
Convenience.StringUtils.contentTableRow("์ด๋ฆ", alertModel.getParamListMap().get(0).get("qnaName")) +
Convenience.StringUtils.contentTableRow("์ฐ๋ฝ์ฒ", alertModel.getParamListMap().get(0).get("qnaPhone")) +
Convenience.StringUtils.contentTableRow("์ด๋ฉ์ผ", alertModel.getParamListMap().get(0).get("qnaEmail")) +
Convenience.StringUtils.contentTableRow("์ ๋ชฉ", alertModel.getParamListMap().get(0).get("qnaTitle")) +
Convenience.StringUtils.contentTableRow("๋ด์ฉ", alertModel.getParamListMap().get(0).get("qnaContent"))
);
//NOTE: Content Table Footer
sb.append(Convenience.StringUtils.contentTableFooter());
} else if (alertModel.getService().equalsIgnoreCase("welpoint")) {
alertModel.setTitle("[์นด๋๊ฒฐ์ ์์คํ
์ถฉ์ ๋ฐฐ์น์๋ฆผ]");
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle("์นด๋๊ฒฐ์ ์์คํ
", "์๋์ถฉ์ ", "์ ์์ฒ๋ฆฌ ๋์์ต๋๋ค.")
);
} else if (alertModel.getService().equalsIgnoreCase("MariaNode")) {
alertModel.setTitle(alertModel.getService() + " ์ด์ ๋ฐ์");
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle("MariaDB", alertModel.getService(), "์ ๊ฐ์๊ฐ 3๊ฐ๊ฐ ์๋๋๋ค. ์ ๊ฒํ์")
);
} else if (alertModel.getService().equalsIgnoreCase("DDC")) {
alertModel.setTitle(alertModel.getService() + " ์ค๋ฅ ๋ฐ์");
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle("DDC", alertModel.getService(), "์ค๋ฅ๊ฐ ๋ฐ์ํ์์ต๋๋ค.")
);
} else if (alertModel.getService().equalsIgnoreCase("DDCDuplicateCheck")) {
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle(alertModel.getParamListMap().get(1).get("PROCID") + " ๋",
alertModel.getContent() + "๋ฑ๋ก์ ํ์
จ์ต๋๋ค.",
"์ ์ฐ ์ฒ๋ฆฌ๋ฅผ ์ํด ํ๊ธฐ ์ ๋ณด ๋ณ๊ฒฝ ๋ถํ๋๋ฆฝ๋๋ค.")
);
//NOTE: Content Table Header
sb.append(Convenience.StringUtils.contentTableHeader());
//NOTE: Content Table
for (int i = 0; i < alertModel.getParamListMap().size(); i++) {
sb.append(
Convenience.StringUtils.contentTableRow("๊ฐ๋งน์ ์ ๋ณด", alertModel.getParamListMap().get(i).get("MERCHANTNAME")) +
Convenience.StringUtils.contentTableRow("์ฌ์
์๋ฒํธ", alertModel.getParamListMap().get(i).get("BUSINESSNO")) +
Convenience.StringUtils.contentTableRow("์ค๋ณต ๋จ๋ง๊ธฐ", alertModel.getParamListMap().get(i).get("TERMINALID")) +
Convenience.StringUtils.contentTableRow("์ค๋ณต Mall ID", alertModel.getParamListMap().get(i).get("PG_MERCH_NBR"))
);
if (i != alertModel.getParamListMap().size() - 1) {
sb.append(Convenience.StringUtils.contentEnterRow());
}
}
//NOTE: Content Table Footer
sb.append(Convenience.StringUtils.contentTableFooter());
} else if (alertModel.getService().equalsIgnoreCase("AdjustCheck")) {
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle(alertModel.getParamListMap().get(1).get("PROCID") + " ๋",
alertModel.getContent() + "๋ฑ๋ก์ ํ์
จ์ต๋๋ค.",
"์ ์ฐ ์ฒ๋ฆฌ๋ฅผ ์ํด ํ๊ธฐ ์ ๋ณด '์๋๋ง๊ฐ'์ '๋งค์ผ์ ์ฐ'์ผ๋ก ๋ณ๊ฒฝ ๋ถํ๋๋ฆฝ๋๋ค.")
);
//NOTE: Content Table Header
sb.append(Convenience.StringUtils.contentTableHeader());
//NOTE: Content Table
sb.append(
Convenience.StringUtils.contentTableRow("๊ฐ๋งน์ ์ ๋ณด", alertModel.getParamListMap().get(0).get("MERCHANTNAME")) +
Convenience.StringUtils.contentTableRow("์ฌ์
์๋ฒํธ", alertModel.getParamListMap().get(0).get("BUSINESSNO")) +
Convenience.StringUtils.contentTableRow("BIZ-TYPE", alertModel.getParamListMap().get(0).get("BIZTYPE")) +
Convenience.StringUtils.contentTableRow("๋จ๋ง๊ธฐ ID", alertModel.getParamListMap().get(0).get("TERMINALID")) +
Convenience.StringUtils.contentTableRow("VAN ID", alertModel.getParamListMap().get(0).get("PG_MERCH_NBR"))
);
//NOTE: Content Table Footer
sb.append(Convenience.StringUtils.contentTableFooter());
} else if (alertModel.getService().equalsIgnoreCase("PAYCO")) {
alertModel.setTitle(alertModel.getService() + " ๋งค์
์๋ ์ฌ์งํ ๊ณต์ ");
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle(alertModel.getService(),
"๋งค์
์ด ์ฌ์งํ ๋์์ต๋๋ค.",
"์ ์์ฒ๋ฆฌ ์ฌ๋ถ ์ต์ข
์ ๊ฒ์ด ํ์ํฉ๋๋ค.")
);
} else if (Convenience.stringUtils(alertModel.getService()).in("CSB", "TMN", "MYB")) {
alertModel.setTitle(alertModel.getService() + " ๋งค์
์ฒ๋ฆฌ ์ค๋ฅ(์ก์ ๋๋ ์์ )");
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle(alertModel.getService(),
"๋งค์
์ค๋ฅ(์ก / ์์ )๊ฐ ๋ฐ์ํ์์ต๋๋ค.",
"๋ฐฐ์น ํ์ธ์ด ํ์ํฉ๋๋ค.")
);
} else if (alertModel.getService().equalsIgnoreCase("prepayUnregisteredTidCheck")) {
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle(alertModel.getTitle(),
alertModel.getContent(),
"ํ์ธํ์ ํ, ์ ๋ณด ๋ฑ๋ก ๋ถํ๋๋ฆฝ๋๋ค."
)
);
//NOTE: Content Table Header
sb.append(Convenience.StringUtils.contentTableHeader());
sb.append("" +
"<table cellspacing=\"0\" width=\"100%\" style=\"table-layout: fixed; margin-top: 16px; border: 1px solid rgb(219, 219, 219); border-collapse: collapse; color: rgb(85, 85, 85); font-family: ๋๋๊ณ ๋, NanumGothic, sans-serif; font-size: 12px; line-height: 18px;\"> \n" +
" <thead style=\"box-sizing: border-box;\">" +
" <tr style=\"box-sizing: border-box;\">" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ๋จ๋ง๊ธฐ ID </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ๊ฐ๋งน์ ๋ฒํธ </th>" +
" </tr>" +
" </thead> \n" +
" <tbody style=\"box-sizing: border-box;\">");
//NOTE: Content Table
for (int i = 0; i < alertModel.getParamListMap().size(); i++) {
sb.append(" <tr style=\"box-sizing: border-box;\">" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("TRML_ID") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("MERCH_NBR") + " </td>" +
" </tr>");
}
sb.append(" </tbody>" +
"</table>");
//NOTE: Content Table Footer
sb.append(Convenience.StringUtils.contentTableFooter());
} else if (alertModel.getService().equalsIgnoreCase("KakaoAlertProcess")) {
alertModel.setTitle(alertModel.getService() + " ์ด์ ์๋ฆผ");
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle(alertModel.getContent(),
"ํ๋ก์ธ์ค ๋ฏธ๋์",
"ํ๋ก์ธ์ค ํ์ธ์ด ํ์ํฉ๋๋ค.")
);
} else if (alertModel.getService().equalsIgnoreCase("KakaoResponse")) {
alertModel.setTitle(alertModel.getService() + " ์ด์ ์๋ฆผ");
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle("์นด์นด์ค ์๋ฆผํก API ์์ ERR ์๋ต์ ๋ณด๋์ต๋๋ค.",
alertModel.getContent(),
"ํ๋ก์ธ์ค ํ์ธ์ด ํ์ํฉ๋๋ค.")
);
} else if (alertModel.getService().equalsIgnoreCase("vmDiskUsageCheck")) {
//NOTE: Content subTitle
sb.append(
Convenience.StringUtils.contentSubTitle("๋ฆฌํฌํธ",
alertModel.getTitle(),
"๋ฐ์ก๋์์ต๋๋ค."
)
);
//NOTE: Content Table Header
sb.append(Convenience.StringUtils.contentTableHeader());
sb.append("" +
"<table cellspacing=\"0\" width=\"100%\" style=\"table-layout: fixed; margin-top: 16px; border: 1px solid rgb(219, 219, 219); border-collapse: collapse; color: rgb(85, 85, 85); font-family: ๋๋๊ณ ๋, NanumGothic, sans-serif; font-size: 12px; line-height: 18px;\"> \n" +
" <thead style=\"box-sizing: border-box;\">" +
" <tr style=\"box-sizing: border-box;\">" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> Host IP </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ์๋น์ค </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ํํฐ์
</th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ํ ๋น๊ฒฝ๋ก </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ํ ๋น์ฉ๋ </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ์ฌ์ฉ์ค </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ์ฌ์ฉ๋(%) </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ์ด ๋ฉ๋ชจ๋ฆฌ </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> free ๋ฉ๋ชจ๋ฆฌ </th>" +
" <th colspan=\"1\" rowspan=\"1\" style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle; background: rgb(245, 245, 247);\"> ๋จ์ ๋ฉ๋ชจ๋ฆฌ </th>" +
" </tr>" +
" </thead> \n" +
" <tbody style=\"box-sizing: border-box;\">");
//NOTE: Content Table
for (int i = 0; i < alertModel.getParamListMap().size(); i++) {
sb.append(" <tr style=\"box-sizing: border-box;\">" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("host") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("service") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("partition") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("path") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("size") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("used") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("percent") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("MemTotal") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("MemFree") + " </td>" +
" <td style=\"box-sizing: border-box; padding: 5px 10px; border: 1px solid rgb(238, 238, 240); text-align: center; vertical-align: middle;\">" + alertModel.getParamListMap().get(i).get("MemAvailable") + " </td>" +
" </tr>");
}
sb.append(" </tbody>" +
"</table>");
//NOTE: Content Table Footer
sb.append(Convenience.StringUtils.contentTableFooter());
}
//์ ์ ๋ฆฌ์์ค
//NOTE: Footer
sb.append(
"<!-- footer -->" +
" <tr>" +
" <td height=\"20\"></td>" +
" </tr>" +
" <tr>" +
" <td style=\"padding-top:26px;padding-left:21px;padding-right:21px;padding-bottom:13px;background:#f9f9f9;font-size:12px;font-family:'๋๋๊ณ ๋',NanumGothic,'๋ง์๊ณ ๋',Malgun Gothic,'๋์',Dotum,Helvetica,'Apple SD Gothic Neo',Sans-serif;color:#696969;line-height:17px\">" +
" ๋ณธ ๋ฉ์ผ์ ๋ฐ์ ์ ์ฉ ์
๋๋ค. ooweat ์๋น์ค๊ด๋ จ ๊ถ๊ธํ์ ์ฌํญ์" +
" <a href=\"http://company.com\" style=\"color:#696969;font-weight:bold;text-decoration:underline\" rel=\"noreferrer noopener\"" +
" target=\"_blank\"> ํํ์ด์ง</a>์์ ํ์ธํด์ฃผ์ธ์." +
" </td>" +
" </tr>" +
" <tr>" +
" <td style=\"padding-left:21px;padding-right:21px;padding-bottom:57px;background:#f9f9f9;font-size:12px;font-family:Helvetica;color:#696969;line-height:17px\">" +
" Copyright โ <strong>ooweat</strong> Corp. All Rights Reserved." +
" </td>" +
" </tr> <!-- //footer --> ");
//NOTE: Table End
sb.append(" </tbody>" +
" </table>" +
"</div>");
if (Convenience.stringUtils(alertModel.getReceiver()).in("sales", "support", "cs", "system")) {
switch (alertModel.getReceiver()) {
case "sales":
message.addRecipients(Message.RecipientType.TO, toSales); //๋ฐ๋ ์ด
message.addRecipients(Message.RecipientType.CC, toSystem); //์ฐธ์กฐ
break;
case "support":
message.addRecipients(Message.RecipientType.TO, toSupport); //๋ฐ๋ ์ด
message.addRecipients(Message.RecipientType.CC, toSystem); //์ฐธ์กฐ
break;
case "cs":
message.addRecipients(Message.RecipientType.TO, toCs); //๋ฐ๋ ์ด
message.addRecipients(Message.RecipientType.CC, toSystem); //์ฐธ์กฐ
break;
case "system":
message.addRecipients(Message.RecipientType.TO, toSystem); //๋ฐ๋ ์ด
break;
}
} else {
message.addRecipients(Message.RecipientType.TO, toTarget);
}
mTextPart.setText(sb.toString(), bodyEncoding, "html");
mParts.addBodyPart(mTextPart);
message.setContent(mParts);
Transport.send(message);
log.info("SEND: {}", "OK");
} catch (SendFailedException e) {
message.addRecipients(Message.RecipientType.TO, toSystem); //๋ฐ๋ ์ด
message.setSubject("โป๋ฉ์ผ๋ฐ์ก์คํจ[" + alertModel.getService() + "] " + alertModel.getTitle());
sb.append(
alertModel.toString() + " <br> \n"
+ "์์ ์์ ์ฌ์ ๋ก ๋ฉ์ผ ๋ฐ์ก์ ์คํจํ์์ต๋๋ค. <br> \n"
+ "</td></tr>"
+ "<tr>"
+ "<td style=\"margin:0; padding:0; height:24px; background-color: white;\"></td></tr><tr><td style=\"margin:0; background-color: white; padding:0 0 0; font-size:14px; letter-spacing:-1px; color:#000000; font-family:'Malgun Gothic', '๋ง์๊ณ ๋', dotum,'๋์',sans-serif; line-height:24px;\">\n<br>\n"
);
mTextPart.setText(sb.toString(), bodyEncoding, "html");
mParts.addBodyPart(mTextPart);
message.setContent(mParts);
Transport.send(message);
log.error("SEND: {}", "FAIL // ์์ ์์ ์ฌ์ ๋ก ๋ฐ์ก๋์ง ์์ต๋๋ค.");
} catch (AddressException e) {
e.printStackTrace();
log.error("SEND: {}", "FAIL // ์ฃผ์๊ฐ ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.");
} catch (MessagingException e) {
e.printStackTrace();
}
}
๋ฐ์ํ