123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554 |
- package kr.co.udapsoft.common.sender;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Properties;
- import javax.mail.Message;
- import javax.mail.MessagingException;
- import javax.mail.Session;
- import javax.mail.Transport;
- import javax.mail.internet.InternetAddress;
- import javax.mail.internet.MimeMessage;
- import kr.co.hsnc.common.base.WAFLogger;
- import kr.co.hsnc.common.logger.Logger;
- import kr.co.hsnc.common.sql.RowSet;
- import kr.co.hsnc.common.sql.RowSetImpl;
- import kr.co.hsnc.common.sql.WAFSQLException;
- import kr.co.hsnc.common.sql.persistent.PersistentImpl;
- import kr.co.hsnc.common.sql.search.Search;
- import kr.co.hsnc.common.sql.search.SearchImpl;
- import com.udapsoft.waf.system.Biz;
- import com.udapsoft.waf.system.HandlerStorage;
- public class MessageSend extends Biz {
- public MessageSend(HandlerStorage storage) {
- super(storage);
- }
-
- public void doBiz() throws Exception {
- }
-
-
- public void sendEmail(String toEmail, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent) throws Exception{
- sendEmail( toEmail, sendUser, mailSubject, subSubject, mailContent, null);
- }
-
- /**
- * 이메일 전송 메소드(Javamail 사용)
- * @param user
- * @param from_email
- * @param to_name
- * @param to_email
- */
- public void sendEmail(String toEmail, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent, String gubun) throws Exception{
-
- Date today=new Date();
- SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
- String date = formater.format(today);
-
- // 메일서버 정보와 실제 서버의 주소를 가져온다.
- RowSet smtpInfo = getSmtpInfo();
- String smtpIp = smtpInfo.getRow(0).get("CHG_CODE01");
- String smtpUser = smtpInfo.getRow(0).get("CHG_CODE02");
- String smtpPw = smtpInfo.getRow(0).get("CHG_CODE03");
- String link = smtpInfo.getRow(0).get("CHG_CODE04");
- String linkPortal = smtpInfo.getRow(0).get("CHG_CODE05");
- sendUser = smtpInfo.getRow(0).get("CHG_CODE06");
- /*
- RowSet userInfo = getUserInfo(sendUser);
- String fromEmail = userInfo.getRow(0).get("E_MAIL");
- String fromName = userInfo.getRow(0).get("USER_NM");
- String fromDuty = userInfo.getRow(0).get("A_DUTY");
- String fromDept = userInfo.getRow(0).get("DEPART_DEPT_NM");
- String fromTel = userInfo.getRow(0).get("TEL_NO");
- */
- Properties properties = new Properties(); // Properties 객체 설정
- properties.put("mail.transport.protocol", "smtp"); // SMTP 프로토콜 사용
- properties.put("mail.smtp.host", smtpIp); // 메일서버 주소 설정
- properties.put("mail.smtp.port", "25"); // 메일서버 포트 설정
- properties.put("mail.smtp.auth", true); // 인증 사용 여부
-
- SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw); // SMTP 인증을 위해서 반드시 필요하다
-
- StringBuffer contentBase = new StringBuffer();
-
- String[] email_domain = toEmail.split("@");
-
- if(gubun == null){
- if("HOTMAIL.COM".equals(email_domain[1].toUpperCase())||"GMAIL.COM".equals(email_domain[1].toUpperCase())){
- contentBase.append(" <body style='padding:0px; margin:0px;'> \n");
- contentBase.append(" <div align='center'> \n");
- 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");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td> \n");
- 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");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td class='popup_logo' width='232' background='"+link+"/img/email/popup_logo.gif' style='background-repeat:no-repeat; width:232px;'> </td> \n");
- contentBase.append(" <td class='popup_title' style='font-family:dotum; font-size:12px; text-indent:10px;'>"+" "+"</td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table> \n");
- contentBase.append(" </td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' background='"+link+"/img/email/img_h_bg.gif' style='height:100%; padding:20px;background-repeat:repeat-y;'> \n");
- contentBase.append(" <table width='700' border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td style='padding:30px 20px 20px 20px;'> \n");
- contentBase.append(" <table width='98%' border='0' cellpadding='0' cellspacing='0' style='border:#CCCCCC dotted 1px;'> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align=center background='"+link+"/img/email/img_h_bg.gif' style='background-repeat:repeat-y; padding-bottom:20px;'> \n");
- contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td><a href='"+linkPortal+"' target='_blank' ><img src="+link+"/img/email/btn_go.gif alt='사이트접속하기' border='0' /></a></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' style='height:50px; vertical-align:top;'> \n");
- contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td><img src="+link+"/img/email/img_mail_footter.jpg /></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' height='30' style='font-size:11px;'>본메일은 발신전용 메일이므로 회신되지 않습니다.</td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table> \n");
- contentBase.append(" </div> \n");
- contentBase.append(" </body> \n");
- }else{
- /*contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> \n");
- contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> \n");
- contentBase.append(" <head> \n");
- contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=euc-kr' /> \n");
- contentBase.append(" <title>:::협력업체포탈_mailing:::</title> \n");
- contentBase.append(" <style type='text/css'> \n");
- contentBase.append(" <!-- \n");
- contentBase.append(" .style1 {color: #3366CC;font-weight: bold;font-size: 24px; border-bottom:#3366CC dotted 2px;} \n");
- contentBase.append(" .popup_table{width:800px; font-family:dotum; font-size:12px; color:#666666; text-align:left;} \n");
- contentBase.append(" .text_red{font-size:12px; color:#cc0000; height:25px; text-align:left; vertical-align:top; text-indent:10px;} \n");
- contentBase.append(" .popup_logo{ background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;} \n");
- contentBase.append(" .popup_title{font-family:dotum; font-size:12px; text-indent:10px;} \n");
- 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");
- 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");
- contentBase.append(" .td_02{ height:28px;line-height:28px;border-top:#cccccc solid 1px; text-indent:20px; font-weight:bold; color:#2f63ac;} \n");
- contentBase.append(" .td_02_2{ height:28px;line-height:28px; text-indent:5px; color:#2f63ac;} \n");
- contentBase.append(" .td_02_3{ line-height:16px; color:#2f63ac; font-size:11px;} \n");
- contentBase.append(" .td_03{ height:300px;line-height:20px;border-top:#cccccc solid 1px; color:#333333; padding:20px;} \n");
- 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");
- contentBase.append(" .text01{width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;} \n");
- contentBase.append(" .text_icon4{color:#ccc; font-size:12px; line-height:16px; width:15px; font-weight:bold;} \n");
- contentBase.append(" .style2 { \n");
- contentBase.append(" font-size: 18px; \n");
- contentBase.append(" font-weight: bold; \n");
- contentBase.append(" } \n");
- contentBase.append(" .style3 {font-size:12px; color:#3366CC; height:25px; text-align:left; vertical-align:top; text-indent:10px;} \n");
- contentBase.append(" .style4 {color: #3366CC;font-weight: bold;font-size: 14px;} \n");
- contentBase.append(" </style> \n");
- contentBase.append(" </head> \n");*/
- contentBase.append(" <body style='padding:0px; margin:0px;'> \n");
- contentBase.append(" <div align='center'> \n");
- 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");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td> \n");
- 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");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td class='popup_logo' width='232' style=' background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;'> </td> \n");
- contentBase.append(" <td class='popup_title' style='font-family:dotum; font-size:12px; text-indent:10px;'>"+" "+"</td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table> \n");
- contentBase.append(" </td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" <table width='700' border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td style='padding:30px 20px 20px 20px;'> \n");
- contentBase.append(" <table width='98%' border='0' cellpadding='0' cellspacing='0' style='border:#CCCCCC dotted 1px;'> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align=center style='background-image:url("+link+"/img/email/img_h_bg.gif); background-repeat:repeat-y; padding-bottom:20px;'> \n");
- contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td><a href='"+linkPortal+"' target='_blank' ><img src="+link+"/img/email/btn_go.gif alt='사이트접속하기' border='0' /></a></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' style='height:50px; vertical-align:top;'> \n");
- contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td><img src="+link+"/img/email/img_mail_footter.jpg /></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' height='30' style='font-size:11px;'>본메일은 발신전용 메일이므로 회신되지 않습니다.</td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table> \n");
- contentBase.append(" </div> \n");
- contentBase.append(" </body> \n");
- //contentBase.append(" </html> \n");
- }
- // 2019.11.29 링크버튼 없는 양식 추가
- }else if(gubun == "NO_LINK"){
- contentBase.append(" <body style='padding:0px; margin:0px;'> \n");
- contentBase.append(" <div align='center'> \n");
- 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");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td> \n");
- 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");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td class='popup_logo' width='232' style=' background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;'> </td> \n");
- contentBase.append(" <td class='popup_title' style='font-family:dotum; font-size:12px; text-indent:10px;'>"+" "+"</td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table> \n");
- contentBase.append(" </td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" <table width='700' border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td style='padding:30px 20px 20px 20px;'> \n");
- contentBase.append(" <table width='98%' border='0' cellpadding='0' cellspacing='0' style='border:#CCCCCC dotted 1px;'> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td height='20' colspan='3'> </td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td height='20' colspan='3'> </td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' style='height:50px; vertical-align:top;'> \n");
- contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td><img src="+link+"/img/email/img_mail_footter.jpg /></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' height='30' style='font-size:11px;'>본메일은 발신전용 메일이므로 회신되지 않습니다.</td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table> \n");
- contentBase.append(" </div> \n");
- contentBase.append(" </body> \n");
- }else{
-
- /*contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> \n");
- contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> \n");
- contentBase.append(" <head> \n");
- contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=euc-kr' /> \n");
- contentBase.append(" <title>:::전자조달_mailing:::</title> \n");
- contentBase.append(" <style type='text/css'> \n");
- contentBase.append(" <!-- \n");
- contentBase.append(" .style1 {color: #3366CC;font-weight: bold;font-size: 24px; border-bottom:#3366CC dotted 2px;} \n");
- contentBase.append(" .popup_table{width:800px; font-family:dotum; font-size:12px; color:#666666; text-align:left;} \n");
- contentBase.append(" .text_red{font-size:12px; color:#cc0000; height:25px; text-align:left; vertical-align:top; text-indent:10px;} \n");
- contentBase.append(" .popup_logo{ background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;} \n");
- contentBase.append(" .popup_title{font-family:dotum; font-size:12px; text-indent:10px;} \n");
- 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");
- 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");
- contentBase.append(" .td_02{ height:28px;line-height:28px;border-top:#cccccc solid 1px; text-indent:20px; font-weight:bold; color:#2f63ac;} \n");
- contentBase.append(" .td_02_2{ height:28px;line-height:28px; text-indent:5px; color:#2f63ac;} \n");
- contentBase.append(" .td_02_3{ line-height:16px; color:#2f63ac; font-size:11px;} \n");
- contentBase.append(" .td_03{ height:300px;line-height:20px;border-top:#cccccc solid 1px; color:#333333; padding:20px;} \n");
- 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");
- contentBase.append(" .text01{width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;} \n");
- contentBase.append(" .text_icon4{color:#ccc; font-size:12px; line-height:16px; width:15px; font-weight:bold;} \n");
- contentBase.append(" .style2 { \n");
- contentBase.append(" font-size: 18px; \n");
- contentBase.append(" font-weight: bold; \n");
- contentBase.append(" } \n");
- contentBase.append(" .style3 {font-size:12px; color:#3366CC; height:25px; text-align:left; vertical-align:top; text-indent:10px;} \n");
- contentBase.append(" .style4 {color: #3366CC;font-weight: bold;font-size: 14px;} \n");
- contentBase.append(" </style> \n");
- contentBase.append(" </head> \n");*/
- contentBase.append(" <body style='padding:0px; margin:0px;'> \n");
- contentBase.append(" <div align='center'> \n");
- 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");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td> \n");
- 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");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td class='popup_logo' width='232' style=' background-image:url("+link+"/img/email/popup_logo.gif) ; background-repeat:no-repeat; width:232px;'> </td> \n");
- contentBase.append(" <td class='popup_title' style='font-family:dotum; font-size:12px; text-indent:10px;'>"+" "+"</td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table> \n");
- contentBase.append(" </td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" <table width='700' border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td style='padding:30px 20px 20px 20px;'> \n");
- contentBase.append(" <table width='98%' border='0' cellpadding='0' cellspacing='0' style='border:#CCCCCC dotted 1px;'> \n");
- contentBase.append(" <tr> \n");
- 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");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td height='20' colspan='3'> </td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td height='20' colspan='3'> </td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align=center style='background-image:url("+link+"/img/email/img_h_bg.gif); background-repeat:repeat-y; padding-bottom:20px;'> \n");
- contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td><a href='"+link+"' target='_blank' ><img src="+link+"/img/email/btn_go02.gif alt='사이트접속하기' border='0' /></a></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' style='height:50px; vertical-align:top;'> \n");
- contentBase.append(" <table border='0' cellspacing='0' cellpadding='0'> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td><img src="+link+"/img/email/img_mail_footter.jpg /></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" <tr> \n");
- contentBase.append(" <td align='center' height='30' style='font-size:11px;'>본메일은 발신전용 메일이므로 회신되지 않습니다.</td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" \n");
- contentBase.append(" </table></td> \n");
- contentBase.append(" </tr> \n");
- contentBase.append(" </table> \n");
- contentBase.append(" </div> \n");
- contentBase.append(" </body> \n");
- //contentBase.append(" </html> \n");
- }
-
- WAFLogger.debug(contentBase);
- try {
-
- Session session = Session.getInstance(properties, auth); // Properties 객체와 auth(인증)객체로 메일전송 세션 생성
- MimeMessage msg = new MimeMessage(session); // 메일 객체를 세션을 통해 생성
-
- InternetAddress[] to_address = {new InternetAddress(toEmail)}; // 받는 사람 메일 주소 객체 생성
- // msg.setFrom(new InternetAddress(sendUser)); // 보내는 사람 메일주소 설정
-
- msg.setFrom(new InternetAddress(new String(sendUser.getBytes("euc-kr"), "8859_1")));
-
-
- msg.setRecipients(Message.RecipientType.TO, to_address); // 받는 사람 메일 주소를 메일 객체에 매핑
- msg.setContent(contentBase.toString(), "text/html; charset=euc-kr"); // 메일 내용을 설정하며 메일 형식을 HTML로 지정
- msg.setSubject(mailSubject,"euc-kr"); // 메일 제목 설정
- msg.setSentDate(new Date()); // 보내는 날짜 설정
-
- Transport.send(msg); // 메일 전송 부분
-
- } catch(MessagingException me) {
- WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + me.getMessage());
- WAFLogger.error(me);
- //throw me;
- } catch(Exception e) {
- WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + e.getMessage());
- WAFLogger.error(e);
- //throw e;
- }
- }
- /**
- * 이메일 전송 메소드(Javamail 사용)
- * @param user
- * @param from_email
- * @param to_name
- * @param to_email
- */
- public void sendSMS(String sendAddress, String recvAddress, String sendUser, String mailContent) throws Exception{
-
-
- try{
- conn.begin();
-
- //2015.3.6 변경
- /*RowSet userInfo = getUserInfo(sendUser);
- if (userInfo.size() > 0 && !userInfo.getRow(0).get("TEL_NO").isEmpty()){
- recvAddress = userInfo.getRow(0).get("TEL_NO").replaceAll("-", "");
- } */
- recvAddress = recvAddress.replaceAll("-","");
- if(recvAddress.trim().equals("")){
- recvAddress = "024899000";
- }
-
- if(!sendAddress.equals("")){
- PersistentImpl persistent = new PersistentImpl(conn.getConnection());
-
- StringBuffer smsInsert = new StringBuffer();
-
-
- smsInsert.append(" INSERT INTO T_SEND(NREGID, \n");
- smsInsert.append(" NSVCTYPE, \n");
- smsInsert.append(" NADDRTYPE, \n");
- smsInsert.append(" SADDRS, \n");
- smsInsert.append(" NCONTSTYPE, \n");
- smsInsert.append(" SCONTS, \n");
- smsInsert.append(" SFROM \n");
- smsInsert.append(" )VALUES( \n");
- smsInsert.append(" UMSBIZ_SENDSEQ.NEXTVAL, \n");
- smsInsert.append(" 3, \n");
- smsInsert.append(" 0, \n");
- smsInsert.append(" ?, \n");
- smsInsert.append(" 0, \n");
- smsInsert.append(" '"+mailContent+"', \n");
- smsInsert.append(" ? \n");
- smsInsert.append(" ) \n");
-
- persistent.setStatement(smsInsert.toString());
-
- persistent.addParameter(sendAddress);
- persistent.addParameter(recvAddress);
-
- persistent.execute();
- persistent.clearParameters();
- }
- }catch(Exception e){
- WAFLogger.error(e);
- e.printStackTrace();
- conn.setRollback();
- }finally{
- conn.end();
- }
- }
-
- private RowSet getSmtpInfo() throws Exception{
-
- Search search = new SearchImpl();
- RowSet rowSet = new RowSetImpl();
-
- StringBuffer sqlstr = new StringBuffer();
-
- try {
- sqlstr.append(" SELECT CHG_CODE01 \n");
- sqlstr.append(" ,CHG_CODE02 \n");
- sqlstr.append(" ,CHG_CODE03 \n");
- sqlstr.append(" ,CHG_CODE04 \n");
- sqlstr.append(" ,CHG_CODE05 \n");
- sqlstr.append(" ,CHG_CODE06 \n");
- sqlstr.append(" FROM EBID_COM910T A \n");
- sqlstr.append(" ,EBID_COM911T B \n");
- sqlstr.append(" WHERE A.BASECD = B.BASECD \n");
- sqlstr.append(" AND A.BASECD = 'EMAIL' \n");
- sqlstr.append(" AND B.DETAILCD = '001' \n");
-
- search.setStatement(sqlstr.toString());
- rowSet = search.execute();
- }
- catch(WAFSQLException se) {
- Logger.err.println("SQL : \n" + se.getStatement());
- Logger.err.println("PARAM : \n" + se.getParameter());
- throw se;
- }
- finally {
- if( rowSet == null ) rowSet = new RowSetImpl();
- return rowSet;
- }
- }
-
- public RowSet getUserInfo(String acctId) throws Exception{
-
- Search search = new SearchImpl();
- RowSet rowSet = new RowSetImpl();
-
- StringBuffer sqlstr = new StringBuffer();
-
- try {
- sqlstr.append(" SELECT BUSEO \n");
- sqlstr.append(" ,GRADE_NAME \n");
- sqlstr.append(" ,USER_NAME \n");
- sqlstr.append(" ,TEL_NO \n");
- sqlstr.append(" ,HAND_TEL_NO \n");
- sqlstr.append(" ,E_MAIL \n");
- sqlstr.append(" FROM PUB0120T \n");
- sqlstr.append(" WHERE ACCT_ID = "+acctId+" \n");
-
- search.setStatement(sqlstr.toString());
- rowSet = search.execute();
- }
- catch(WAFSQLException se) {
- Logger.err.println("SQL : \n" + se.getStatement());
- Logger.err.println("PARAM : \n" + se.getParameter());
- throw se;
- }
- finally {
- if( rowSet == null ) rowSet = new RowSetImpl();
- return rowSet;
- }
- }
- //메일 메세지 가져오기
- public RowSet getMailMessage(String detailCd) throws Exception {
-
- Search search = new SearchImpl();
- RowSet rowSet = new RowSetImpl();
-
- StringBuffer sqlstr = new StringBuffer();
-
- try {
- sqlstr.append(" SELECT CHG_CODE01 AS TITLE \n");
- sqlstr.append(" ,CHG_CODE02 AS SUBTITLE \n");
- sqlstr.append(" ,CHG_CODE03 \n");
- sqlstr.append(" ||CHG_CODE04 \n");
- sqlstr.append(" ||CHG_CODE05 AS CONTENTS1 \n");
- sqlstr.append(" ,CHG_CODE06 AS CONTENTS2 \n");
- sqlstr.append(" FROM EBID_COM911T B \n");
- sqlstr.append(" ,EBID_COM910T A \n");
- sqlstr.append(" WHERE A.BASECD = B.BASECD \n");
- sqlstr.append(" AND A.BASECD = 'EMAIL_CONT' \n");
- sqlstr.append(" AND B.DETAILCD = '"+detailCd+"' \n");
-
- search.setStatement(sqlstr.toString());
- rowSet = search.execute();
- }
- catch(WAFSQLException se) {
- Logger.err.println("SQL : \n" + se.getStatement());
- Logger.err.println("PARAM : \n" + se.getParameter());
- throw se;
- }
- finally {
- if( rowSet == null ) rowSet = new RowSetImpl();
- }
- return rowSet;
- }
- }
|