본문 바로가기

Spring/smtp

smtp 설정 및 설치

728x90

1. application.yml 설정

spring:
  mail:
    host: smtp.gmail.com
    port: 587
    username: bangbae   #bangbae@naver.com
    password:           # 앱 비밀번호는 구글 계정, 16자리 설정 
    properties:
      mail:
        smtp:
          auth: true
          timeout : 5000
          starttls:
            enable: true

 

2. 계정관리 - 보안 - 앱 비밀번호 검색

google 계정 관리

3. 생성된 앱 비밀번호 - 구글 계정 설정 

4. 구글 메일 설정

1)Gmail (모든)설정에 들어가서 전달 및 POP/IMAP 탭으로 들어간다.

2)모든 메일에 POP를 활성화 하기를 선택한다.

*IMAP(Internet Message Access Protocol) : IMAP을 사용하면 어디서나 전자 메일에 액세스할 수 있음 

 

3) IMAP 사용

 

5.smtp  라이브러리 

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-mail</artifactId>
    <version>3.3.2</version>
</dependency>

6. thymeleaf 라이브러리 설치

<!-- thymeleaf-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
    <version>3.0.0</version>
</dependency>

 

728x90