-
Notifications
You must be signed in to change notification settings - Fork 5
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
9 changed files
with
211 additions
and
5 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/main/java/com/sparta/oneandzerobest/auth/config/MailConfig.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,42 @@ | ||
package com.sparta.oneandzerobest.auth.config; | ||
|
||
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; | ||
|
||
import java.util.Properties; | ||
|
||
@Configuration | ||
public class MailConfig { | ||
@Value("${spring.mail.host}") | ||
private String mailHost; | ||
|
||
@Value("${spring.mail.port}") | ||
private int mailPort; | ||
|
||
@Value("${spring.mail.username}") | ||
private String mailUsername; | ||
|
||
@Value("${spring.mail.password}") | ||
private String mailPassword; | ||
|
||
@Bean | ||
public JavaMailSender javaMailSender() { | ||
JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); | ||
mailSender.setHost(mailHost); | ||
mailSender.setPort(mailPort); | ||
mailSender.setUsername(mailUsername); | ||
mailSender.setPassword(mailPassword); | ||
|
||
Properties props = mailSender.getJavaMailProperties(); | ||
props.put("mail.transport.protocol", "smtp"); | ||
props.put("mail.smtp.auth", "true"); | ||
props.put("mail.smtp.starttls.enable", "true"); | ||
props.put("mail.debug", "true"); | ||
|
||
return mailSender; | ||
|
||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/sparta/oneandzerobest/auth/config/RedisConfig.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,21 @@ | ||
package com.sparta.oneandzerobest.auth.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
|
||
@Configuration | ||
public class RedisConfig { | ||
|
||
@Bean | ||
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory connectionFactory) { | ||
RedisTemplate<String, String> template = new RedisTemplate<>(); | ||
template.setConnectionFactory(connectionFactory); | ||
template.setKeySerializer(new StringRedisSerializer()); | ||
template.setValueSerializer(new StringRedisSerializer()); | ||
return template; | ||
} | ||
} |
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
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/sparta/oneandzerobest/auth/service/EmailService.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,25 @@ | ||
package com.sparta.oneandzerobest.auth.service; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.mail.SimpleMailMessage; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class EmailService { | ||
private final JavaMailSender javaMailSender; | ||
|
||
@Value("${spring.mail.username}") | ||
private String from; | ||
public EmailService(JavaMailSender javaMailSender) { | ||
this.javaMailSender = javaMailSender; | ||
} | ||
public void sendEmail(String to, String subject, String text) { | ||
SimpleMailMessage message = new SimpleMailMessage(); | ||
message.setFrom(from); | ||
message.setTo(to); | ||
message.setSubject(subject); | ||
message.setText(text); | ||
javaMailSender.send(message); | ||
} | ||
} |
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
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
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
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