fix : 메일발송 설정
This commit is contained in:
@@ -33,8 +33,8 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'javax.mail:javax.mail-api:1.6.2'
|
||||
implementation 'com.sun.mail:javax.mail:1.6.2'
|
||||
// implementation 'javax.mail:javax.mail-api:1.6.2'
|
||||
implementation 'com.sun.mail:jakarta.mail:2.0.1'
|
||||
|
||||
implementation 'org.springframework.cloud:spring-cloud-starter'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import jakarta.mail.*;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -27,11 +28,6 @@ import com.wb.domainserver.util.dataaccess.DataMap;
|
||||
|
||||
import jakarta.activation.CommandMap;
|
||||
import jakarta.activation.MailcapCommandMap;
|
||||
import jakarta.mail.Message;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Multipart;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.Transport;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
@@ -69,6 +65,17 @@ public class BOEmailService {
|
||||
private String host;
|
||||
@Value("${mail.port}")
|
||||
private String port;
|
||||
@Value("${mail.username}")
|
||||
private String username;
|
||||
@Value("${mail.password}")
|
||||
private String password;
|
||||
@Value("${mail.connectiontimeout}")
|
||||
private String connectiontimeout;
|
||||
@Value("${mail.timeout}")
|
||||
private String timeout;
|
||||
@Value("${mail.writetimeout}")
|
||||
private String writetimeout;
|
||||
|
||||
|
||||
/* ####################################
|
||||
이메일 발송 서비스 시작
|
||||
@@ -202,12 +209,7 @@ public class BOEmailService {
|
||||
SopmalNm = mapper.selectBOEmailSopmalNm(ListOne);
|
||||
}
|
||||
|
||||
Properties props = System.getProperties();
|
||||
props.put("mail.smtp.host", host);
|
||||
props.put("mail.smtp.port", port);
|
||||
log.info("이메일 발송 SMTP 메소드 진입 확인 => {}", host+":"+port);
|
||||
|
||||
Session session = Session.getInstance(props, null);
|
||||
Session session = this.getMailSession();
|
||||
|
||||
int i = 0;
|
||||
for(BOEmailVO vo : voList) {
|
||||
@@ -337,12 +339,7 @@ public class BOEmailService {
|
||||
SopmalNm = mapper.selectBOEmailSopmalNm(ListOne);
|
||||
}
|
||||
|
||||
Properties props = System.getProperties();
|
||||
props.put("mail.smtp.host", host);
|
||||
props.put("mail.smtp.port", port);
|
||||
log.info("이메일 발송 SMTP 메소드 진입 확인 => {}", host+":"+port);
|
||||
|
||||
Session session = Session.getInstance(props, null);
|
||||
Session session = this.getMailSession();
|
||||
|
||||
int i = 0;
|
||||
for(BOEmailVO vo : voList) {
|
||||
@@ -464,10 +461,8 @@ public class BOEmailService {
|
||||
/**
|
||||
* 메시지 내 치환코드에 따라 변경 처리
|
||||
* @param cn
|
||||
* @param param
|
||||
* @param replaceMap
|
||||
* @param caseNm
|
||||
* @return
|
||||
* @return String
|
||||
*/
|
||||
public String mssageConvert(String cn, DataMap replaceMap) {
|
||||
//필요에 따라 db 갈수 도 있으나 현재는 없다고 판단함
|
||||
@@ -503,4 +498,37 @@ public class BOEmailService {
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
private Session getMailSession(){
|
||||
Properties props = System.getProperties();
|
||||
props.put("mail.smtp.host", host);
|
||||
props.put("mail.smtp.port", port);
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
props.put("mail.smtp.starttls.required", "true");
|
||||
|
||||
props.put("mail.smtp.connectiontimeout", connectiontimeout);
|
||||
props.put("mail.smtp.timeout", timeout);
|
||||
props.put("mail.smtp.writetimeout", writetimeout);
|
||||
|
||||
props.put("mail.debug", "true");
|
||||
|
||||
log.info("이메일 발송 SMTP 메소드 진입 확인 => {}", host+":"+port);
|
||||
Session session = null;
|
||||
|
||||
try {
|
||||
Authenticator auth = new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
};
|
||||
|
||||
session = Session.getInstance(props, auth);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ public class BbsmngrController {
|
||||
* @return
|
||||
*/
|
||||
@Policy(AuthPolicy.RESTRICTED)
|
||||
@RequestMapping(value="/selectBbsIdDplctCnfirm", method = RequestMethod.GET)
|
||||
@RequestMapping(value="/selectBbsIdDplctCnfirm", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<WnbtResponse> selectBbsIdDplctCnfirm(BOBbsVO vo, @CookieValue(value = "authSopmalCd") String authSopmalCd){
|
||||
|
||||
List<Map<String, String>> errorList = new ArrayList<>();
|
||||
|
||||
@@ -55,7 +55,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static org.springframework.beans.factory.config.BeanDefinition.ROLE_INFRASTRUCTURE;
|
||||
|
||||
@EnableWebSecurity(debug = true)
|
||||
@EnableWebSecurity(debug = false)
|
||||
@Configuration
|
||||
//@EnableMethodSecurity
|
||||
public class ResourceServerConfig {
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package com.wb.domainserver.util.file.service;
|
||||
|
||||
import com.wb.domainserver.util.file.vo.EmailProperties;
|
||||
import jakarta.activation.DataHandler;
|
||||
import jakarta.activation.FileDataSource;
|
||||
import jakarta.mail.*;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -8,13 +15,6 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
@@ -30,7 +30,7 @@ public class MailSenderSvc {
|
||||
|
||||
// 보낼사람의 이메일,제목 , 내용
|
||||
@Async
|
||||
public void sendMail(String toEmail, String fromEmail, String subject, String text, File file) throws MessagingException{
|
||||
public void sendMail(String toEmail, String fromEmail, String subject, String text, File file) throws MessagingException {
|
||||
|
||||
String smtpHostServer = emailProperties.getHost();
|
||||
String senderEmail = fromEmail;
|
||||
|
||||
@@ -378,9 +378,13 @@ naverpay:
|
||||
real-url: https://pay.naver.com
|
||||
|
||||
mail:
|
||||
host: 127.0.0.1
|
||||
port: 25
|
||||
username: celebpay@inssoft.kr
|
||||
host: mail.soju1sake1.com
|
||||
port: 587
|
||||
username: custom@soju1sake1.com
|
||||
password: mail13@$
|
||||
connectiontimeout: 10000
|
||||
timeout: 10000
|
||||
writetimeout: 10000
|
||||
|
||||
|
||||
#이지웰페이 정보
|
||||
|
||||
@@ -378,9 +378,13 @@ naverpay:
|
||||
real-url: https://pay.naver.com
|
||||
|
||||
mail:
|
||||
host: 127.0.0.1
|
||||
port: 25
|
||||
username: celebpay@inssoft.kr
|
||||
host: mail.soju1sake1.com
|
||||
port: 587
|
||||
username: custom@soju1sake1.com
|
||||
password: mail13@$
|
||||
connectiontimeout: 10000
|
||||
timeout: 10000
|
||||
writetimeout: 10000
|
||||
|
||||
|
||||
#이지웰페이 정보
|
||||
|
||||
@@ -378,9 +378,13 @@ naverpay:
|
||||
real-url: https://pay.naver.com
|
||||
|
||||
mail:
|
||||
host: 127.0.0.1
|
||||
port: 25
|
||||
username: celebpay@inssoft.kr
|
||||
host: mail.soju1sake1.com
|
||||
port: 587
|
||||
username: custom@soju1sake1.com
|
||||
password: mail13@$
|
||||
connectiontimeout: 10000
|
||||
timeout: 10000
|
||||
writetimeout: 10000
|
||||
|
||||
|
||||
#이지웰페이 정보
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<%@ page import="java.util.Date" %>
|
||||
<spring:eval expression="@environment.getProperty('mail.username')" var="sndrEmail"/>
|
||||
<%--
|
||||
Class Name : EmailPassivSndngC.jsp
|
||||
Description : 이메일 수동 발송 폼
|
||||
@@ -73,8 +74,8 @@
|
||||
<th>보내는 사람</th>
|
||||
<td>
|
||||
<div class="td-inner">
|
||||
<input class="input-text xl" type="text" title="해당 인풋에 대한 설명" name="sndrEmail" id="sndrEmail"
|
||||
placeholder="메일 주소 입력">
|
||||
<input class="input-text xl" type="text" title="해당 인풋에 대한 설명" name="sndrEmail" id="sndrEmail" value='<c:out value="${sndrEmail}"/>'
|
||||
placeholder="메일 주소 입력" readonly>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -98,7 +99,7 @@
|
||||
<th>받는 사람 (직접 입력)</th>
|
||||
<td>
|
||||
<div class="td-inner">
|
||||
<input class="input-text xl" type="text" title="해당 인풋에 대한 설명" name="recpntEmail" id="recpntEmail"
|
||||
<input class="input-text xl" type="text" title="해당 인풋에 대한 설명" name="recpntEmail" id="recpntEmail"/>'
|
||||
placeholder="메일 주소는 ,(콤마)로 구분하여 입력">
|
||||
</div>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user