142 lines
4.9 KiB
Java
142 lines
4.9 KiB
Java
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 org.springframework.stereotype.Service;
|
|
|
|
import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
|
import kcc.com.cmm.LoginVO;
|
|
import kcc.com.cmm.service.EgovFileMngUtil;
|
|
import kcc.ve.instr.tngrVisitEdu.eduInfo.service.VEEduAplctVO;
|
|
|
|
@Service("btchVeBatchSendMailing")
|
|
public class VeBatchSendMailing extends EgovAbstractServiceImpl {
|
|
|
|
|
|
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 void VeSendMail() throws Exception {
|
|
|
|
/*
|
|
try {
|
|
System.out.println("수정_220221_10:49");
|
|
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.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 = "school@copyright.or.kr";
|
|
String pw = "dustndnjs2669!";
|
|
|
|
String id = "no-reply@copyright.or.kr";
|
|
String pw = "Copycopy12!";
|
|
|
|
if("C".equals(sndFlag)) {
|
|
id = "school@copyright.or.kr";
|
|
pw = "dustndnjs2669!";
|
|
}else if("S".equals(sndFlag)) {
|
|
id = "edu@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!";
|
|
}
|
|
|
|
return new PasswordAuthentication(id,pw);
|
|
}
|
|
};
|
|
|
|
//메일 내용
|
|
String Cn = vEEduAplctVO.getSndCn();
|
|
|
|
//발송메일 주소
|
|
String fromAddr = "no-reply@copyright.or.kr";
|
|
if("C".equals(sndFlag)) {
|
|
fromAddr = "school@copyright.or.kr";
|
|
}else if("S".equals(sndFlag)) {
|
|
fromAddr = "edu@copyright.or.kr";
|
|
}else if("G".equals(sndFlag)) {
|
|
fromAddr = "entt@copyright.or.kr";
|
|
}else if("W".equals(sndFlag)) {
|
|
fromAddr = "cev@copyright.or.kr";
|
|
}
|
|
|
|
Session session = Session.getInstance(props, authenticator) ;
|
|
|
|
InternetAddress fromAddress = new InternetAddress(fromAddr);
|
|
InternetAddress toAddress = new InternetAddress(sndTo);
|
|
MimeMessage message = new MimeMessage(session);
|
|
message.setFrom(fromAddress);
|
|
message.addRecipient(Message.RecipientType.TO, toAddress );
|
|
message.setSubject("[한국 저작권 위원회] 찾아가는 교육서비스_알림");
|
|
message.setContent(Cn," text/html; charset=KSC5601");
|
|
System.out.println("------------------ 메일발송 시작 ----------------");
|
|
Transport.send(message);
|
|
System.out.println("------------------ 메일발송 끝 ----------------");
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if("success".equals(result)) {
|
|
//메일 발송 로그
|
|
String snd_ord = sndGnrService.getNextStringId();
|
|
vEEduAplctVO.setSndHstryOrd(snd_ord);
|
|
|
|
vEEduAplctVO.setSndId(loginVO.getUniqId());
|
|
|
|
vEEduAplctSndHstryService.insert(vEEduAplctVO);
|
|
}
|
|
|
|
*/
|
|
/*System.out.println("배치 테스트");*/
|
|
}
|
|
|
|
}
|