-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : Java Mail Sender Config 세팅 (#28)
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/main/java/com/gdschongik/gdsc/domain/integration/JavaMailSenderConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.gdschongik.gdsc.domain.integration; | ||
|
||
import java.util.Properties; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.mail.javamail.JavaMailSenderImpl; | ||
|
||
@Configuration | ||
public class JavaMailSenderConfig { | ||
|
||
@Value("${gmail.id}") | ||
private String id; | ||
|
||
@Value("${gmail.password}") | ||
private String password; | ||
|
||
@Bean | ||
public JavaMailSender javaMailSender() { | ||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); | ||
javaMailSender.setHost("smtp.gmail.com"); | ||
javaMailSender.setPort(456); | ||
javaMailSender.setUsername(id); | ||
javaMailSender.setPassword(password); | ||
javaMailSender.setJavaMailProperties(getMailProperties()); | ||
javaMailSender.setDefaultEncoding("UTF-8"); | ||
return javaMailSender; | ||
} | ||
|
||
private Properties getMailProperties() { | ||
Properties properties = new Properties(); | ||
properties.put("mail.smtp.socketFactory.port", 456); | ||
properties.put("mail.smtp.auth", true); | ||
properties.put("mail.smtp.starttls.enable", true); | ||
properties.put("mail.smtp.starttls.required", true); | ||
properties.put("mail.smtp.socketFactory.fallback", false); | ||
properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); | ||
return properties; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters