- 구글 계정 설정
- 계정 > 보안 > 2단계 인증 사용설정
- 보안 > 앱비밀번호 > 원하는 앱 이름 입력 = 앱비밀번호 생성
- Gmail > 라벨 관리 > 전달 및 POP/MAP : POP 사용 / IMAP 사용 체크 후 저장 - pom.xml 의존성 추가
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency>
- 설정 추가
- properties 파일의 경우
spring.mail.default-encoding=UTF-8 spring.mail.host=smtp.gmail.com spring.mail.port=587 spring.mail.username=구글계정 spring.mail.password=앱 비밀번호 spring.mail.properties.mail.smtp.starttls.enable=true spring.mail.properties.mail.smtp.starttls.required=true spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.debug=true spring.mail.properties.mail.mime.charset=UTF-8 spring.mail.properties.mail.transport.protocol=smtp
- yaml 파일의 경우
spring:
mail:
properties:
mail:
debug: true
smtp:
starttls:
enable: true
required: true
auth: true
mime:
charset: UTF-8
transport:
protocol: smtp
host: smtp.gmail.com
username: 구글계정
password: 앱 비밀번호
port: 587
default-encoding: UTF-8
※ 587 포트
SMTPS 포트(465포트)와 비슷하지만, SMTPS포트는 오래된 방식의 통신이며, 최근에는 587 포트를 사용하는 것이 더 보안적으로 권장됨.
587 포트는 MSA포트(Message Submisstion Agent)로 알려져있음.
MSA 는 인증 후 전자 메일을 수락해야하며,
클라이언트 애플리케이션이 이메일을 이메일 서버로 안전하게(TLS/SSL 암호화 후 전송) 제출하기 위해 사용됨
'JAVA' 카테고리의 다른 글
Map.Entry와 Map.getKey 차이 (0) | 2024.12.29 |
---|---|
중첩 클래스 (0) | 2024.12.22 |
동시성 문제와 동기화(synchronized) (0) | 2024.11.24 |
멀티스레드 메모리 접근 방식/메모리 가시성/happens-before (0) | 2024.11.21 |
스레드와 Yield (0) | 2024.11.18 |