티스토리 뷰
@Data
@Configuration
@ConfigurationProperties(prefix="smtp")
public class SMTPConfig {
private String host;
private String port;
private Boolean auth;
private Boolean startTLSEnable;
private String user;
private String password;
/**--------------------------------------------------------------------
* ■서비스 등록
--------------------------------------------------------------------**/
@Bean
public JavaMailSender getMailSender() {
JavaMailSenderImpl objJavaMailSenderImpl = new JavaMailSenderImpl();
objJavaMailSenderImpl.setJavaMailProperties(getMailProperties());
// 인증 계정이 있는 경우
if(auth) {
objJavaMailSenderImpl.setUsername(user);
objJavaMailSenderImpl.setPassword(password);
Session session = Session.getInstance(getMailProperties(), new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
});
session.setDebug(true);
}
return objJavaMailSenderImpl;
}
/**--------------------------------------------------------------------
* ■SMTP 프로퍼티 설정
--------------------------------------------------------------------**/
private Properties getMailProperties() {
Properties properties = new Properties();
properties.setProperty("mail.transport.protocol", "smtp");
properties.setProperty("mail.smtp.starttls.enable", startTLSEnable ? "true" : "false");
properties.setProperty("mail.smtp.ssl.trust", host);
properties.setProperty("mail.smtp.host", host);
properties.setProperty("mail.smtp.auth", auth ? "true" : "false");
properties.setProperty("mail.smtp.port", port);
properties.setProperty("mail.smtp.socketFactory.port", port);
properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
return properties;
}
}
'Skill > spring' 카테고리의 다른 글
java] 메일 보내기 (0) | 2025.03.04 |
---|---|
Query Timeout 적용 최종 (0) | 2025.01.13 |
ServiceInitializer.java (0) | 2025.01.13 |
ServiceInit.java (0) | 2025.01.13 |
ServiceConfig.java (0) | 2025.01.13 |
- Total
- Today
- Yesterday
- border-collapse
- getter
- springboot
- 진열사랑
- Keycode
- excel
- element위치
- QueryDSL
- DatePicker
- 정규식
- $.each
- JQuery
- lombok
- spring
- draw.io
- 프로젝트명변경
- ul li로 테이블
- oracle
- setter
- 여러 컬럼 update
- $.extend
- sumifs
- 전후방탐색
- @ExceptionHandler
- Javascript
- object key
- caniuse
- devtools
- PostgreSQL
- CSS
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |