package kcc.ve.cmm; import java.util.Properties; import javax.mail.Authenticator; import javax.mail.Message; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import kcc.com.cmm.LoginVO; import kcc.com.cmm.service.EgovFileMngUtil; import kcc.ve.instr.tngrVisitEdu.eduInfo.service.VEEduAplctVO; public class VeSendMail { private static final Logger LOGGER = LoggerFactory.getLogger(EgovFileMngUtil.class); //================================================================ //찾교 메일 발송 계정 ID, PW 넣는 부분 //테스트를 위한 저작위 공통 계정 ID: no-reply@copyright.or.kr PW: Copycopy12! //찾교만 추가되어 찾교는 현재 메일발송 안됨_220221 //기존(찾교청소년) ID: school@copyright.or.kr PW: 연수원2669! //신규(찾교성인) ID: edu@copyright.or.kr PW: Copy0723! //기존(체험교실) ID: entt@copyright.or.kr PW: edu0213** //신규(외부협력) ID: cev@copyright.or.kr PW: Copy0723! //================================================================ //파라미터 정리 //1. sndFlag = 메뉴 구분 // C -> 찾교청소년 // S -> 찾교성인 // G -> 체험교실 // W -> 외부협력 //2. sndTo = 수신자 //3. vEEduAplctVO = eduAplctOrd(pk) // sndHstryOrd(pk) // sndCd(10 - sms, 20 - email) // sndId(발송자) // sndCn(발송내용) //================================================================ public String VeSendMail(String sndFlag, String sndTo, VEEduAplctVO vEEduAplctVO, LoginVO loginVO) throws Exception { String result = "success"; System.out.println("vEEduAplctVO.getClphone1()"); System.out.println(sndFlag); System.out.println(vEEduAplctVO.getClphone1()); System.out.println(vEEduAplctVO.getClphone2()); System.out.println("vEEduAplctVO.getClphone2()"); try { System.out.println("수정_2200317_12:46"); Properties props = new Properties(); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.host", "smtp.gov-dooray.com"); props.put("mail.smtp.port", "465"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.ssl.enable", "true"); // props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.ssl.protocols", "TLSv1"); props.put("mail.smtp.ssl.protocols", "TLSv1.1"); props.put("mail.smtp.ssl.protocols", "TLSv1.2"); props.put("mail.debug", "true"); Authenticator authenticator = new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { String id = "no-reply@copyright.or.kr"; String pw = "Copycopy12!"; /*231120 - 성인 교육용 메일 정보 불일치 > 전부 청소년 메일로 우선 사용*/ id = "school@copyright.or.kr"; pw = "dustndnjs2669!"; /*if("C".equals(sndFlag) || "Z".equals(sndFlag)) { id = "school@copyright.or.kr"; //pw = "연수원2669!"; pw = "dustndnjs2669!"; }else if("S".equals(sndFlag)) { id = "kedu@copyright.or.kr"; pw = "Copy0723!"; }else if("G".equals(sndFlag)) { id = "entt@copyright.or.kr"; pw = "edu0213**"; }else if("W".equals(sndFlag)) { id = "cev@copyright.or.kr"; pw = "Copy0723!"; }else if("UR".equals(sndFlag)) { id = vEEduAplctVO.getClphone1(); pw = vEEduAplctVO.getClphone2(); }*/ System.out.println(id); System.out.println(pw); System.out.println("vEEduAplctVO.getClphone3()"); return new PasswordAuthentication(id,pw); } }; Session session = Session.getInstance(props, authenticator) ; MimeMessage message = new MimeMessage(session); //메일 내용 String Cn = vEEduAplctVO.getSndCn(); //메일 내용 textarea 작성 시, 메일에 Enter 반영 if(!"".equals(Cn) && Cn != null) { Cn = Cn.replaceAll("\n", "
"); } //메일제목 message.setSubject("[한국저작권위원회] 찾아가는 교육서비스_알림"); //발송메일 주소 String fromAddr = "no-reply@copyright.or.kr"; if("C".equals(sndFlag)) { fromAddr = "school@copyright.or.kr"; }else if("Z".equals(sndFlag)) { fromAddr = "school@copyright.or.kr"; message.setSubject("[한국저작권위원회] 찾아가는 저작권 교육관련 협조요청 사항"); }else if("S".equals(sndFlag)) { fromAddr = "kedu@copyright.or.kr"; }else if("G".equals(sndFlag)) { fromAddr = "entt@copyright.or.kr"; }else if("W".equals(sndFlag)) { fromAddr = "cev@copyright.or.kr"; //메일제목 message.setSubject("[한국저작권위원회] 저작권 교육콘텐츠 수령 방법 안내"); //메일내용 Cn = "\r\n" + "\r\n" + "\r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + "\r\n" + "\r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + "
\r\n" + " \"한국저작권위원회-통합회원\r\n" + "
\r\n" + "

\r\n" + " 안녕하세요~
한국저작권위원회 교육개발팀 조혜진 주임입니다.

저작권 교육에 관심을 가지고 신청해주셔서 진심으로 감사드립니다.

메일 하단에 ‘콘텐츠 수령 방법’에 대한 안내 링크가 있습니다.
클릭하여 다운로드 후, 안내 방법에 따라 신청하신 동영상 파일을 저장하여 사용하시면 됩니다.

교육 종료 후에는 ‘수강내역목록-강의이수정보등록’을 통해 이수내용(교육일시/교육인원) 작성 부탁드립니다. 교육이수 확인을 위해 필요한 과정이므로 반드시 등록해주시기 바랍니다.

더불어 신규과정으로 마이크로러닝 콘텐츠 6종을 함께 추천해 드립니다.
마이크로러닝 콘텐츠는 3분 정도의 숏폼 콘텐츠로 학교(초·중·고·대), 공공기관 등을 대상으로 제작한 5종과 가볍게 볼 수 있는 아이스브레이킹 영상 1종으로 구성되어 있습니다.

교육 시작 전이나 쉬는 시간에 분위기 전환을 위해 활용하시기 좋으며, 관심 있으신 선생님께서는 아래 링크를 통해 신청 부탁드립니다.
※ 마이크로러닝 콘텐츠 신청하기: https://www.copyright.or.kr/offedu

교육과정 안내 및 콘텐츠 신청과 관련된 추가 문의사항은
아래 번호로 연락주시면 상세히 안내해드리도록 하겠습니다.

감사합니다.

조혜진 드림

☎ 055-792-0217

[클릭하여 다운로드] ‘콘텐츠 수령 방법 안내’\r\n" + "

\r\n" + "
\r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + "
\r\n" + " \"한국저작권위원회-통합회원\r\n" + " \r\n" + "

본 메일은 발신전용으로 회신하지 않습니다.

\r\n" + "

진주 [우 52852] 경상남도 진주시 충의로 19, 1/2/5층.  대표번호 : 055.792.0000
서울 [우 04323] 서울특별시 용산구 후암로 107, 5/16층.  대표번호 : 02.2669.0010

\r\n" + "
\r\n" + "
\r\n" + "\r\n" + ""; } InternetAddress fromAddress = new InternetAddress(fromAddr); InternetAddress toAddress = new InternetAddress(sndTo); message.setFrom(fromAddress); message.addRecipient(Message.RecipientType.TO, toAddress ); message.setContent(Cn," text/html; charset=KSC5601"); System.out.println("------------------ 메일발송 시작 ----------------"); Transport.send(message); System.out.println("------------------ 메일발송 끝 ----------------"); } catch (Exception e) { e.printStackTrace(); result = "fail"; } return result; } }