회원가입 시 이메일 인증, 비밀번호를 분실했을 때 임시 비밀번호를 발송하는 기능을 구현하기위해 Gmail의 SMTP 서버를 활용하고자 한다.
⚙️ SMTP란?
간이 전자 우편 전송 프로토콜(Simple Mail Transfer Protocol, SMTP)
인터넷에서 이메일을 보내기 위해 이용되는 프로토콜이다. 메일 서버간의 송수신뿐만 아니라,
메일 클라이언트에서 메일 서버로 메일을 보낼 때에도 사용되는 경우가 많다.
개발 환경




dependencies {
...
implementation 'org.springframework.boot:spring-boot-starter-mail'
// 아래 2개는 thymeleaf를 사용하는 경우에만 추가
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
...
}
*Spring Boot Starter Mail
메일서버와 연결해서 메일을 발송하는데 필요한 라이브러리
## gmail ##
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=이메일계정
spring.mail.password=앱비밀번호
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class EmailDto {
private String address;
private String title;
private String content;
}