-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/main/java/com/hackathon/momento/global/config/EmailConfig.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,50 @@ | ||
package com.hackathon.momento.global.config; | ||
|
||
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 EmailConfig { | ||
|
||
@Value("${spring.mail.host}") | ||
private String host; | ||
|
||
@Value("${spring.mail.port}") | ||
private int port; | ||
|
||
@Value("${spring.mail.username}") | ||
private String username; | ||
|
||
@Value("${spring.mail.password}") | ||
private String password; | ||
|
||
@Bean | ||
public JavaMailSender javaMailSender() { | ||
JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); | ||
mailSender.setPort(port); | ||
mailSender.setHost(host); | ||
mailSender.setUsername(username); | ||
mailSender.setPassword(password); | ||
mailSender.setDefaultEncoding("UTF-8"); | ||
mailSender.setJavaMailProperties(getMailProperties()); | ||
|
||
return mailSender; | ||
} | ||
|
||
private Properties getMailProperties() { | ||
Properties properties = new Properties(); | ||
properties.put("mail.smtp.auth", true); | ||
properties.put("mail.smtp.starttls.enable", true); | ||
properties.put("mail.smtp.starttls.required", true); | ||
properties.put("mail.smtp.connectiontimeout", 5000); | ||
properties.put("mail.smtp.timeout", 5000); | ||
properties.put("mail.smtp.writetimeout", 5000); | ||
|
||
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