MessageSend.java 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. package kr.co.udapsoft.common.sender;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Date;
  4. import java.util.Properties;
  5. import javax.mail.Message;
  6. import javax.mail.MessagingException;
  7. import javax.mail.Session;
  8. import javax.mail.Transport;
  9. import javax.mail.internet.InternetAddress;
  10. import javax.mail.internet.MimeMessage;
  11. import kr.co.hsnc.common.base.WAFLogger;
  12. import kr.co.hsnc.common.logger.Logger;
  13. import kr.co.hsnc.common.sql.RowSet;
  14. import kr.co.hsnc.common.sql.RowSetImpl;
  15. import kr.co.hsnc.common.sql.WAFSQLException;
  16. import kr.co.hsnc.common.sql.persistent.PersistentImpl;
  17. import kr.co.hsnc.common.sql.search.Search;
  18. import kr.co.hsnc.common.sql.search.SearchImpl;
  19. import com.udapsoft.waf.system.Biz;
  20. import com.udapsoft.waf.system.HandlerStorage;
  21. public class MessageSend extends Biz {
  22. public MessageSend(HandlerStorage storage) {
  23. super(storage);
  24. }
  25. public void doBiz() throws Exception {
  26. }
  27. public void sendEmail(String toEmail, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent) throws Exception{
  28. sendEmail( toEmail, sendUser, mailSubject, subSubject, mailContent, null);
  29. }
  30. /**
  31. * 이메일 전송 메소드(Javamail 사용)
  32. * @param user
  33. * @param from_email
  34. * @param to_name
  35. * @param to_email
  36. */
  37. public void sendEmail(String toEmail, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent, String gubun) throws Exception{
  38. Date today=new Date();
  39. SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
  40. String date = formater.format(today);
  41. // 메일서버 정보와 실제 서버의 주소를 가져온다.
  42. RowSet smtpInfo = getSmtpInfo();
  43. String smtpIp = smtpInfo.getRow(0).get("CHG_CODE01");
  44. String smtpUser = smtpInfo.getRow(0).get("CHG_CODE02");
  45. String smtpPw = smtpInfo.getRow(0).get("CHG_CODE03");
  46. String link = smtpInfo.getRow(0).get("CHG_CODE04");
  47. String linkPortal = smtpInfo.getRow(0).get("CHG_CODE05");
  48. sendUser = smtpInfo.getRow(0).get("CHG_CODE06");
  49. /*
  50. RowSet userInfo = getUserInfo(sendUser);
  51. String fromEmail = userInfo.getRow(0).get("E_MAIL");
  52. String fromName = userInfo.getRow(0).get("USER_NM");
  53. String fromDuty = userInfo.getRow(0).get("A_DUTY");
  54. String fromDept = userInfo.getRow(0).get("DEPART_DEPT_NM");
  55. String fromTel = userInfo.getRow(0).get("TEL_NO");
  56. */
  57. Properties properties = new Properties(); // Properties 객체 설정
  58. properties.put("mail.transport.protocol", "smtp"); // SMTP 프로토콜 사용
  59. properties.put("mail.smtp.host", smtpIp); // 메일서버 주소 설정
  60. properties.put("mail.smtp.port", "25"); // 메일서버 포트 설정
  61. properties.put("mail.smtp.auth", true); // 인증 사용 여부
  62. SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw); // SMTP 인증을 위해서 반드시 필요하다
  63. StringBuffer contentBase = new StringBuffer();
  64. String[] email_domain = toEmail.split("@");
  65. if(gubun == null){
  66. if("HOTMAIL.COM".equals(email_domain[1].toUpperCase())||"GMAIL.COM".equals(email_domain[1].toUpperCase())){
  67. contentBase.append(" <body style='padding:0px; margin:0px;'> \n");
  68. contentBase.append(" <div align='center'> \n");
  69. contentBase.append(" <table border='0' cellpadding='0' cellspacing='0' class='popup_table' style='width:800px; font-family:dotum; font-size:12px; color:#666666; text-align:left;'> \n");
  70. contentBase.append(" <tr> \n");
  71. contentBase.append(" <td> \n");
  72. contentBase.append(" <table border='0' cellpadding='0' cellspacing='0' background='"+link+"/img/email/img_mail_title.gif' style='width:800px; height:62px;background-repeat:no-repeat;'> \n");
  73. contentBase.append(" <tr> \n");
  74. contentBase.append(" <td class='popup_logo' width='232' background='"+link+"/img/email/popup_logo.gif' style='background-repeat:no-repeat; width:232px;'>&nbsp;</td> \n");
  75. contentBase.append(" <td class='popup_title' style='font-family:dotum; font-size:12px; text-indent:10px;'>"+" "+"</td> \n");
  76. contentBase.append(" </tr> \n");
  77. contentBase.append(" </table> \n");
  78. contentBase.append(" </td> \n");
  79. contentBase.append(" </tr> \n");
  80. contentBase.append(" <tr> \n");
  81. contentBase.append(" <td align='center' background='"+link+"/img/email/img_h_bg.gif' style='height:100%; padding:20px;background-repeat:repeat-y;'> \n");
  82. contentBase.append(" <table width='700' border='0' cellspacing='0' cellpadding='0'> \n");
  83. contentBase.append(" <tr> \n");
  84. contentBase.append(" <td height='50' align='center' class='style1' style='color: #3366CC;font-weight: bold;font-size: 24px; border-bottom:#3366CC dotted 2px;'>"+subSubject+"</td> \n");
  85. contentBase.append(" </tr> \n");
  86. contentBase.append(" <tr> \n");
  87. contentBase.append(" <td style='padding:30px 20px 20px 20px;'> \n");
  88. contentBase.append(" <table width='98%' border='0' cellpadding='0' cellspacing='0' style='border:#CCCCCC dotted 1px;'> \n");
  89. contentBase.append(" <tr> \n");
  90. contentBase.append(" <td height='20' colspan='3' style='line-height:24px; font-size:14px; font-weight:bold; text-align:left; padding:15px;'>"+mailContent+"</td> \n");
  91. contentBase.append(" </tr> \n");
  92. contentBase.append(" </table></td> \n");
  93. contentBase.append(" </tr> \n");
  94. contentBase.append(" </table></td> \n");
  95. contentBase.append(" <tr> \n");
  96. contentBase.append(" <td align=center background='"+link+"/img/email/img_h_bg.gif' style='background-repeat:repeat-y; padding-bottom:20px;'> \n");
  97. contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
  98. contentBase.append(" <tr> \n");
  99. contentBase.append(" <td><a href='"+linkPortal+"' target='_blank' ><img src="+link+"/img/email/btn_go.gif alt='사이트접속하기' border='0' /></a></td> \n");
  100. contentBase.append(" </tr> \n");
  101. contentBase.append(" </table></td> \n");
  102. contentBase.append(" </tr> \n");
  103. contentBase.append(" <tr> \n");
  104. contentBase.append(" <td align='center' style='height:50px; vertical-align:top;'> \n");
  105. contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
  106. contentBase.append(" <tr> \n");
  107. contentBase.append(" <td><img src="+link+"/img/email/img_mail_footter.jpg /></td> \n");
  108. contentBase.append(" </tr> \n");
  109. contentBase.append(" <tr> \n");
  110. contentBase.append(" <td align='center' height='30' style='font-size:11px;'>본메일은 발신전용 메일이므로 회신되지 않습니다.</td> \n");
  111. contentBase.append(" </tr> \n");
  112. contentBase.append(" \n");
  113. contentBase.append(" </table></td> \n");
  114. contentBase.append(" </tr> \n");
  115. contentBase.append(" </table> \n");
  116. contentBase.append(" </div> \n");
  117. contentBase.append(" </body> \n");
  118. }else{
  119. /*contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> \n");
  120. contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> \n");
  121. contentBase.append(" <head> \n");
  122. contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=euc-kr' /> \n");
  123. contentBase.append(" <title>:::협력업체포탈_mailing:::</title> \n");
  124. contentBase.append(" <style type='text/css'> \n");
  125. contentBase.append(" <!-- \n");
  126. contentBase.append(" .style1 {color: #3366CC;font-weight: bold;font-size: 24px; border-bottom:#3366CC dotted 2px;} \n");
  127. contentBase.append(" .popup_table{width:800px; font-family:dotum; font-size:12px; color:#666666; text-align:left;} \n");
  128. contentBase.append(" .text_red{font-size:12px; color:#cc0000; height:25px; text-align:left; vertical-align:top; text-indent:10px;} \n");
  129. contentBase.append(" .popup_logo{ background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;} \n");
  130. contentBase.append(" .popup_title{font-family:dotum; font-size:12px; text-indent:10px;} \n");
  131. contentBase.append(" .td_01{ height:28px; background-color:#f5f9fe; line-height:28px; text-indent:20px; border-top:#cccccc solid 1px; border-right:#cccccc solid 1px; width:130px; font-weight:bold; color:#333333;} \n");
  132. contentBase.append(" .td_01_2{ height:28px; background-color:#f5f9fe; line-height:28px; text-indent:20px; border-top:#cccccc solid 1px; border-right:#cccccc solid 1px;border-bottom:#cccccc solid 1px; width:130px; font-weight:bold; color:#333333;} \n");
  133. contentBase.append(" .td_02{ height:28px;line-height:28px;border-top:#cccccc solid 1px; text-indent:20px; font-weight:bold; color:#2f63ac;} \n");
  134. contentBase.append(" .td_02_2{ height:28px;line-height:28px; text-indent:5px; color:#2f63ac;} \n");
  135. contentBase.append(" .td_02_3{ line-height:16px; color:#2f63ac; font-size:11px;} \n");
  136. contentBase.append(" .td_03{ height:300px;line-height:20px;border-top:#cccccc solid 1px; color:#333333; padding:20px;} \n");
  137. contentBase.append(" .td_04{ height:28px;line-height:28px;border-top:#cccccc solid 1px; text-indent:20px; color:#666666;border-bottom:#cccccc solid 1px;} \n");
  138. contentBase.append(" .text01{width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;} \n");
  139. contentBase.append(" .text_icon4{color:#ccc; font-size:12px; line-height:16px; width:15px; font-weight:bold;} \n");
  140. contentBase.append(" .style2 { \n");
  141. contentBase.append(" font-size: 18px; \n");
  142. contentBase.append(" font-weight: bold; \n");
  143. contentBase.append(" } \n");
  144. contentBase.append(" .style3 {font-size:12px; color:#3366CC; height:25px; text-align:left; vertical-align:top; text-indent:10px;} \n");
  145. contentBase.append(" .style4 {color: #3366CC;font-weight: bold;font-size: 14px;} \n");
  146. contentBase.append(" </style> \n");
  147. contentBase.append(" </head> \n");*/
  148. contentBase.append(" <body style='padding:0px; margin:0px;'> \n");
  149. contentBase.append(" <div align='center'> \n");
  150. contentBase.append(" <table border='0' cellpadding='0' cellspacing='0' class='popup_table' style='width:800px; font-family:dotum; font-size:12px; color:#666666; text-align:left;'> \n");
  151. contentBase.append(" <tr> \n");
  152. contentBase.append(" <td> \n");
  153. contentBase.append(" <table border='0' cellpadding='0' cellspacing='0' style='width:800px; height:62px; background-image:url("+link+"/img/email/img_mail_title.gif); background-repeat:no-repeat;'> \n");
  154. contentBase.append(" <tr> \n");
  155. contentBase.append(" <td class='popup_logo' width='232' style=' background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;'>&nbsp;</td> \n");
  156. contentBase.append(" <td class='popup_title' style='font-family:dotum; font-size:12px; text-indent:10px;'>"+" "+"</td> \n");
  157. contentBase.append(" </tr> \n");
  158. contentBase.append(" </table> \n");
  159. contentBase.append(" </td> \n");
  160. contentBase.append(" </tr> \n");
  161. contentBase.append(" <tr> \n");
  162. contentBase.append(" <td align='center' style='height:100%; padding:20px; background-image:url("+link+"/img/email/img_h_bg.gif); background-repeat:repeat-y;'> \n");
  163. contentBase.append(" <table width='700' border='0' cellspacing='0' cellpadding='0'> \n");
  164. contentBase.append(" <tr> \n");
  165. contentBase.append(" <td height='50' align='center' class='style1' style='color: #3366CC;font-weight: bold;font-size: 24px; border-bottom:#3366CC dotted 2px;'>"+subSubject+"</td> \n");
  166. contentBase.append(" </tr> \n");
  167. contentBase.append(" <tr> \n");
  168. contentBase.append(" <td style='padding:30px 20px 20px 20px;'> \n");
  169. contentBase.append(" <table width='98%' border='0' cellpadding='0' cellspacing='0' style='border:#CCCCCC dotted 1px;'> \n");
  170. contentBase.append(" <tr> \n");
  171. contentBase.append(" <td height='20' colspan='3' style='line-height:24px; font-size:14px; font-weight:bold; text-align:left; padding:15px;'>"+mailContent+"</td> \n");
  172. contentBase.append(" </tr> \n");
  173. contentBase.append(" </table></td> \n");
  174. contentBase.append(" </tr> \n");
  175. contentBase.append(" </table></td> \n");
  176. contentBase.append(" <tr> \n");
  177. contentBase.append(" <td align=center style='background-image:url("+link+"/img/email/img_h_bg.gif); background-repeat:repeat-y; padding-bottom:20px;'> \n");
  178. contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
  179. contentBase.append(" <tr> \n");
  180. contentBase.append(" <td><a href='"+linkPortal+"' target='_blank' ><img src="+link+"/img/email/btn_go.gif alt='사이트접속하기' border='0' /></a></td> \n");
  181. contentBase.append(" </tr> \n");
  182. contentBase.append(" </table></td> \n");
  183. contentBase.append(" </tr> \n");
  184. contentBase.append(" <tr> \n");
  185. contentBase.append(" <td align='center' style='height:50px; vertical-align:top;'> \n");
  186. contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
  187. contentBase.append(" <tr> \n");
  188. contentBase.append(" <td><img src="+link+"/img/email/img_mail_footter.jpg /></td> \n");
  189. contentBase.append(" </tr> \n");
  190. contentBase.append(" <tr> \n");
  191. contentBase.append(" <td align='center' height='30' style='font-size:11px;'>본메일은 발신전용 메일이므로 회신되지 않습니다.</td> \n");
  192. contentBase.append(" </tr> \n");
  193. contentBase.append(" \n");
  194. contentBase.append(" </table></td> \n");
  195. contentBase.append(" </tr> \n");
  196. contentBase.append(" </table> \n");
  197. contentBase.append(" </div> \n");
  198. contentBase.append(" </body> \n");
  199. //contentBase.append(" </html> \n");
  200. }
  201. // 2019.11.29 링크버튼 없는 양식 추가
  202. }else if(gubun == "NO_LINK"){
  203. contentBase.append(" <body style='padding:0px; margin:0px;'> \n");
  204. contentBase.append(" <div align='center'> \n");
  205. contentBase.append(" <table border='0' cellpadding='0' cellspacing='0' class='popup_table' style='width:800px; font-family:dotum; font-size:12px; color:#666666; text-align:left;'> \n");
  206. contentBase.append(" <tr> \n");
  207. contentBase.append(" <td> \n");
  208. contentBase.append(" <table border='0' cellpadding='0' cellspacing='0' style='width:800px; height:62px; background-image:url("+link+"/img/email/img_mail_title02.gif); background-repeat:no-repeat;'> \n");
  209. contentBase.append(" <tr> \n");
  210. contentBase.append(" <td class='popup_logo' width='232' style=' background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;'>&nbsp;</td> \n");
  211. contentBase.append(" <td class='popup_title' style='font-family:dotum; font-size:12px; text-indent:10px;'>"+" "+"</td> \n");
  212. contentBase.append(" </tr> \n");
  213. contentBase.append(" </table> \n");
  214. contentBase.append(" </td> \n");
  215. contentBase.append(" </tr> \n");
  216. contentBase.append(" <tr> \n");
  217. contentBase.append(" <td align='center' style='height:100%; padding:20px; background-image:url("+link+"/img/email/img_h_bg.gif); background-repeat:repeat-y;'> \n");
  218. contentBase.append(" <table width='700' border='0' cellspacing='0' cellpadding='0'> \n");
  219. contentBase.append(" <tr> \n");
  220. contentBase.append(" <td height='50' align='center' class='style1' style='color: #3366CC;font-weight: bold;font-size: 24px; border-bottom:#3366CC dotted 2px;'>"+subSubject+"</td> \n");
  221. contentBase.append(" </tr> \n");
  222. contentBase.append(" <tr> \n");
  223. contentBase.append(" <td style='padding:30px 20px 20px 20px;'> \n");
  224. contentBase.append(" <table width='98%' border='0' cellpadding='0' cellspacing='0' style='border:#CCCCCC dotted 1px;'> \n");
  225. contentBase.append(" <tr> \n");
  226. contentBase.append(" <td height='20' colspan='3' style='line-height:24px; font-size:14px; font-weight:bold; text-align:left; padding:15px;'>"+mailContent+"</td> \n");
  227. contentBase.append(" </tr> \n");
  228. contentBase.append(" <tr> \n");
  229. contentBase.append(" <td height='20' colspan='3'>&nbsp;</td> \n");
  230. contentBase.append(" </tr> \n");
  231. contentBase.append(" <tr> \n");
  232. contentBase.append(" <td height='20' colspan='3'>&nbsp;</td> \n");
  233. contentBase.append(" </tr> \n");
  234. contentBase.append(" </table></td> \n");
  235. contentBase.append(" </tr> \n");
  236. contentBase.append(" </table></td> \n");
  237. contentBase.append(" </tr> \n");
  238. contentBase.append(" <tr> \n");
  239. contentBase.append(" <td align='center' style='height:50px; vertical-align:top;'> \n");
  240. contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
  241. contentBase.append(" <tr> \n");
  242. contentBase.append(" <td><img src="+link+"/img/email/img_mail_footter.jpg /></td> \n");
  243. contentBase.append(" </tr> \n");
  244. contentBase.append(" <tr> \n");
  245. contentBase.append(" <td align='center' height='30' style='font-size:11px;'>본메일은 발신전용 메일이므로 회신되지 않습니다.</td> \n");
  246. contentBase.append(" </tr> \n");
  247. contentBase.append(" \n");
  248. contentBase.append(" </table></td> \n");
  249. contentBase.append(" </tr> \n");
  250. contentBase.append(" </table> \n");
  251. contentBase.append(" </div> \n");
  252. contentBase.append(" </body> \n");
  253. }else{
  254. /*contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> \n");
  255. contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> \n");
  256. contentBase.append(" <head> \n");
  257. contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=euc-kr' /> \n");
  258. contentBase.append(" <title>:::전자조달_mailing:::</title> \n");
  259. contentBase.append(" <style type='text/css'> \n");
  260. contentBase.append(" <!-- \n");
  261. contentBase.append(" .style1 {color: #3366CC;font-weight: bold;font-size: 24px; border-bottom:#3366CC dotted 2px;} \n");
  262. contentBase.append(" .popup_table{width:800px; font-family:dotum; font-size:12px; color:#666666; text-align:left;} \n");
  263. contentBase.append(" .text_red{font-size:12px; color:#cc0000; height:25px; text-align:left; vertical-align:top; text-indent:10px;} \n");
  264. contentBase.append(" .popup_logo{ background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;} \n");
  265. contentBase.append(" .popup_title{font-family:dotum; font-size:12px; text-indent:10px;} \n");
  266. contentBase.append(" .td_01{ height:28px; background-color:#f5f9fe; line-height:28px; text-indent:20px; border-top:#cccccc solid 1px; border-right:#cccccc solid 1px; width:130px; font-weight:bold; color:#333333;} \n");
  267. contentBase.append(" .td_01_2{ height:28px; background-color:#f5f9fe; line-height:28px; text-indent:20px; border-top:#cccccc solid 1px; border-right:#cccccc solid 1px;border-bottom:#cccccc solid 1px; width:130px; font-weight:bold; color:#333333;} \n");
  268. contentBase.append(" .td_02{ height:28px;line-height:28px;border-top:#cccccc solid 1px; text-indent:20px; font-weight:bold; color:#2f63ac;} \n");
  269. contentBase.append(" .td_02_2{ height:28px;line-height:28px; text-indent:5px; color:#2f63ac;} \n");
  270. contentBase.append(" .td_02_3{ line-height:16px; color:#2f63ac; font-size:11px;} \n");
  271. contentBase.append(" .td_03{ height:300px;line-height:20px;border-top:#cccccc solid 1px; color:#333333; padding:20px;} \n");
  272. contentBase.append(" .td_04{ height:28px;line-height:28px;border-top:#cccccc solid 1px; text-indent:20px; color:#666666;border-bottom:#cccccc solid 1px;} \n");
  273. contentBase.append(" .text01{width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;} \n");
  274. contentBase.append(" .text_icon4{color:#ccc; font-size:12px; line-height:16px; width:15px; font-weight:bold;} \n");
  275. contentBase.append(" .style2 { \n");
  276. contentBase.append(" font-size: 18px; \n");
  277. contentBase.append(" font-weight: bold; \n");
  278. contentBase.append(" } \n");
  279. contentBase.append(" .style3 {font-size:12px; color:#3366CC; height:25px; text-align:left; vertical-align:top; text-indent:10px;} \n");
  280. contentBase.append(" .style4 {color: #3366CC;font-weight: bold;font-size: 14px;} \n");
  281. contentBase.append(" </style> \n");
  282. contentBase.append(" </head> \n");*/
  283. contentBase.append(" <body style='padding:0px; margin:0px;'> \n");
  284. contentBase.append(" <div align='center'> \n");
  285. contentBase.append(" <table border='0' cellpadding='0' cellspacing='0' class='popup_table' style='width:800px; font-family:dotum; font-size:12px; color:#666666; text-align:left;'> \n");
  286. contentBase.append(" <tr> \n");
  287. contentBase.append(" <td> \n");
  288. contentBase.append(" <table border='0' cellpadding='0' cellspacing='0' style='width:800px; height:62px; background-image:url("+link+"/img/email/img_mail_title02.gif); background-repeat:no-repeat;'> \n");
  289. contentBase.append(" <tr> \n");
  290. contentBase.append(" <td class='popup_logo' width='232' style=' background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;'>&nbsp;</td> \n");
  291. contentBase.append(" <td class='popup_title' style='font-family:dotum; font-size:12px; text-indent:10px;'>"+" "+"</td> \n");
  292. contentBase.append(" </tr> \n");
  293. contentBase.append(" </table> \n");
  294. contentBase.append(" </td> \n");
  295. contentBase.append(" </tr> \n");
  296. contentBase.append(" <tr> \n");
  297. contentBase.append(" <td align='center' style='height:100%; padding:20px; background-image:url("+link+"/img/email/img_h_bg.gif); background-repeat:repeat-y;'> \n");
  298. contentBase.append(" <table width='700' border='0' cellspacing='0' cellpadding='0'> \n");
  299. contentBase.append(" <tr> \n");
  300. contentBase.append(" <td height='50' align='center' class='style1' style='color: #3366CC;font-weight: bold;font-size: 24px; border-bottom:#3366CC dotted 2px;'>"+subSubject+"</td> \n");
  301. contentBase.append(" </tr> \n");
  302. contentBase.append(" <tr> \n");
  303. contentBase.append(" <td style='padding:30px 20px 20px 20px;'> \n");
  304. contentBase.append(" <table width='98%' border='0' cellpadding='0' cellspacing='0' style='border:#CCCCCC dotted 1px;'> \n");
  305. contentBase.append(" <tr> \n");
  306. contentBase.append(" <td height='20' colspan='3' style='line-height:24px; font-size:14px; font-weight:bold; text-align:left; padding:15px;'>"+mailContent+"</td> \n");
  307. contentBase.append(" </tr> \n");
  308. contentBase.append(" <tr> \n");
  309. contentBase.append(" <td height='20' colspan='3'>&nbsp;</td> \n");
  310. contentBase.append(" </tr> \n");
  311. contentBase.append(" <tr> \n");
  312. contentBase.append(" <td height='20' colspan='3'>&nbsp;</td> \n");
  313. contentBase.append(" </tr> \n");
  314. contentBase.append(" </table></td> \n");
  315. contentBase.append(" </tr> \n");
  316. contentBase.append(" </table></td> \n");
  317. contentBase.append(" <tr> \n");
  318. contentBase.append(" <td align=center style='background-image:url("+link+"/img/email/img_h_bg.gif); background-repeat:repeat-y; padding-bottom:20px;'> \n");
  319. contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
  320. contentBase.append(" <tr> \n");
  321. contentBase.append(" <td><a href='"+link+"' target='_blank' ><img src="+link+"/img/email/btn_go02.gif alt='사이트접속하기' border='0' /></a></td> \n");
  322. contentBase.append(" </tr> \n");
  323. contentBase.append(" </table></td> \n");
  324. contentBase.append(" </tr> \n");
  325. contentBase.append(" <tr> \n");
  326. contentBase.append(" <td align='center' style='height:50px; vertical-align:top;'> \n");
  327. contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
  328. contentBase.append(" <tr> \n");
  329. contentBase.append(" <td><img src="+link+"/img/email/img_mail_footter.jpg /></td> \n");
  330. contentBase.append(" </tr> \n");
  331. contentBase.append(" <tr> \n");
  332. contentBase.append(" <td align='center' height='30' style='font-size:11px;'>본메일은 발신전용 메일이므로 회신되지 않습니다.</td> \n");
  333. contentBase.append(" </tr> \n");
  334. contentBase.append(" \n");
  335. contentBase.append(" </table></td> \n");
  336. contentBase.append(" </tr> \n");
  337. contentBase.append(" </table> \n");
  338. contentBase.append(" </div> \n");
  339. contentBase.append(" </body> \n");
  340. //contentBase.append(" </html> \n");
  341. }
  342. WAFLogger.debug(contentBase);
  343. try {
  344. Session session = Session.getInstance(properties, auth); // Properties 객체와 auth(인증)객체로 메일전송 세션 생성
  345. MimeMessage msg = new MimeMessage(session); // 메일 객체를 세션을 통해 생성
  346. InternetAddress[] to_address = {new InternetAddress(toEmail)}; // 받는 사람 메일 주소 객체 생성
  347. // msg.setFrom(new InternetAddress(sendUser)); // 보내는 사람 메일주소 설정
  348. msg.setFrom(new InternetAddress(new String(sendUser.getBytes("euc-kr"), "8859_1")));
  349. msg.setRecipients(Message.RecipientType.TO, to_address); // 받는 사람 메일 주소를 메일 객체에 매핑
  350. msg.setContent(contentBase.toString(), "text/html; charset=euc-kr"); // 메일 내용을 설정하며 메일 형식을 HTML로 지정
  351. msg.setSubject(mailSubject,"euc-kr"); // 메일 제목 설정
  352. msg.setSentDate(new Date()); // 보내는 날짜 설정
  353. Transport.send(msg); // 메일 전송 부분
  354. } catch(MessagingException me) {
  355. WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + me.getMessage());
  356. WAFLogger.error(me);
  357. //throw me;
  358. } catch(Exception e) {
  359. WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + e.getMessage());
  360. WAFLogger.error(e);
  361. //throw e;
  362. }
  363. }
  364. /**
  365. * 이메일 전송 메소드(Javamail 사용)
  366. * @param user
  367. * @param from_email
  368. * @param to_name
  369. * @param to_email
  370. */
  371. public void sendSMS(String sendAddress, String recvAddress, String sendUser, String mailContent) throws Exception{
  372. try{
  373. conn.begin();
  374. //2015.3.6 변경
  375. /*RowSet userInfo = getUserInfo(sendUser);
  376. if (userInfo.size() > 0 && !userInfo.getRow(0).get("TEL_NO").isEmpty()){
  377. recvAddress = userInfo.getRow(0).get("TEL_NO").replaceAll("-", "");
  378. } */
  379. recvAddress = recvAddress.replaceAll("-","");
  380. if(recvAddress.trim().equals("")){
  381. recvAddress = "024899000";
  382. }
  383. if(!sendAddress.equals("")){
  384. PersistentImpl persistent = new PersistentImpl(conn.getConnection());
  385. StringBuffer smsInsert = new StringBuffer();
  386. smsInsert.append(" INSERT INTO T_SEND(NREGID, \n");
  387. smsInsert.append(" NSVCTYPE, \n");
  388. smsInsert.append(" NADDRTYPE, \n");
  389. smsInsert.append(" SADDRS, \n");
  390. smsInsert.append(" NCONTSTYPE, \n");
  391. smsInsert.append(" SCONTS, \n");
  392. smsInsert.append(" SFROM \n");
  393. smsInsert.append(" )VALUES( \n");
  394. smsInsert.append(" UMSBIZ_SENDSEQ.NEXTVAL, \n");
  395. smsInsert.append(" 3, \n");
  396. smsInsert.append(" 0, \n");
  397. smsInsert.append(" ?, \n");
  398. smsInsert.append(" 0, \n");
  399. smsInsert.append(" '"+mailContent+"', \n");
  400. smsInsert.append(" ? \n");
  401. smsInsert.append(" ) \n");
  402. persistent.setStatement(smsInsert.toString());
  403. persistent.addParameter(sendAddress);
  404. persistent.addParameter(recvAddress);
  405. persistent.execute();
  406. persistent.clearParameters();
  407. }
  408. }catch(Exception e){
  409. WAFLogger.error(e);
  410. e.printStackTrace();
  411. conn.setRollback();
  412. }finally{
  413. conn.end();
  414. }
  415. }
  416. private RowSet getSmtpInfo() throws Exception{
  417. Search search = new SearchImpl();
  418. RowSet rowSet = new RowSetImpl();
  419. StringBuffer sqlstr = new StringBuffer();
  420. try {
  421. sqlstr.append(" SELECT CHG_CODE01 \n");
  422. sqlstr.append(" ,CHG_CODE02 \n");
  423. sqlstr.append(" ,CHG_CODE03 \n");
  424. sqlstr.append(" ,CHG_CODE04 \n");
  425. sqlstr.append(" ,CHG_CODE05 \n");
  426. sqlstr.append(" ,CHG_CODE06 \n");
  427. sqlstr.append(" FROM EBID_COM910T A \n");
  428. sqlstr.append(" ,EBID_COM911T B \n");
  429. sqlstr.append(" WHERE A.BASECD = B.BASECD \n");
  430. sqlstr.append(" AND A.BASECD = 'EMAIL' \n");
  431. sqlstr.append(" AND B.DETAILCD = '001' \n");
  432. search.setStatement(sqlstr.toString());
  433. rowSet = search.execute();
  434. }
  435. catch(WAFSQLException se) {
  436. Logger.err.println("SQL : \n" + se.getStatement());
  437. Logger.err.println("PARAM : \n" + se.getParameter());
  438. throw se;
  439. }
  440. finally {
  441. if( rowSet == null ) rowSet = new RowSetImpl();
  442. return rowSet;
  443. }
  444. }
  445. public RowSet getUserInfo(String acctId) throws Exception{
  446. Search search = new SearchImpl();
  447. RowSet rowSet = new RowSetImpl();
  448. StringBuffer sqlstr = new StringBuffer();
  449. try {
  450. sqlstr.append(" SELECT BUSEO \n");
  451. sqlstr.append(" ,GRADE_NAME \n");
  452. sqlstr.append(" ,USER_NAME \n");
  453. sqlstr.append(" ,TEL_NO \n");
  454. sqlstr.append(" ,HAND_TEL_NO \n");
  455. sqlstr.append(" ,E_MAIL \n");
  456. sqlstr.append(" FROM PUB0120T \n");
  457. sqlstr.append(" WHERE ACCT_ID = "+acctId+" \n");
  458. search.setStatement(sqlstr.toString());
  459. rowSet = search.execute();
  460. }
  461. catch(WAFSQLException se) {
  462. Logger.err.println("SQL : \n" + se.getStatement());
  463. Logger.err.println("PARAM : \n" + se.getParameter());
  464. throw se;
  465. }
  466. finally {
  467. if( rowSet == null ) rowSet = new RowSetImpl();
  468. return rowSet;
  469. }
  470. }
  471. //메일 메세지 가져오기
  472. public RowSet getMailMessage(String detailCd) throws Exception {
  473. Search search = new SearchImpl();
  474. RowSet rowSet = new RowSetImpl();
  475. StringBuffer sqlstr = new StringBuffer();
  476. try {
  477. sqlstr.append(" SELECT CHG_CODE01 AS TITLE \n");
  478. sqlstr.append(" ,CHG_CODE02 AS SUBTITLE \n");
  479. sqlstr.append(" ,CHG_CODE03 \n");
  480. sqlstr.append(" ||CHG_CODE04 \n");
  481. sqlstr.append(" ||CHG_CODE05 AS CONTENTS1 \n");
  482. sqlstr.append(" ,CHG_CODE06 AS CONTENTS2 \n");
  483. sqlstr.append(" FROM EBID_COM911T B \n");
  484. sqlstr.append(" ,EBID_COM910T A \n");
  485. sqlstr.append(" WHERE A.BASECD = B.BASECD \n");
  486. sqlstr.append(" AND A.BASECD = 'EMAIL_CONT' \n");
  487. sqlstr.append(" AND B.DETAILCD = '"+detailCd+"' \n");
  488. search.setStatement(sqlstr.toString());
  489. rowSet = search.execute();
  490. }
  491. catch(WAFSQLException se) {
  492. Logger.err.println("SQL : \n" + se.getStatement());
  493. Logger.err.println("PARAM : \n" + se.getParameter());
  494. throw se;
  495. }
  496. finally {
  497. if( rowSet == null ) rowSet = new RowSetImpl();
  498. }
  499. return rowSet;
  500. }
  501. }