JavaMailSender_설정

SunA·2020년 8월 3일
0

💡 이메일 전송 기능을 구현을 위한 설정 내용을 정리한다. 💡

📌 설정을 진행하기 전, 반드시 각 메일 계정에서 smtp를 허용하도록 설정해야 한다.

pom.xml 설정 후 Maven Update

<!-- Mail -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-mail</artifactId>
</dependency>

application.properties 설정

✅ git hub과 같이 소스코드를 공유하는 곳에 올릴 때에는 반드시 gitignore에 해당 파일을 추가하여 비밀번호를 보호해야한다.

구글

  • 메일 계정 작성 시, @gmail.com은 생략!!

    # 구글 설정
    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

네이버

  • username 에 네이버 로그인 시의 아이디를 작성한다.

    # 네이버 설정
    spring.mail.host=smtp.naver.com
    spring.mail.port=465
    spring.mail.username={아이디}
    spring.mail.password={비밀번호}
    spring.mail.properties.mail.smtp.auth=true
    spring.mail.properties.mail.smtp.ssl.enable=true
profile
꾸준하게 열심히!

0개의 댓글