-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserVerificationEmailService.java
More file actions
61 lines (53 loc) · 2.61 KB
/
UserVerificationEmailService.java
File metadata and controls
61 lines (53 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package learningFlow.learningFlow_BE.service.auth.common;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
@Slf4j
public class UserVerificationEmailService {
private final JavaMailSender emailSender;
@Value("${app.url}")
private String baseUrl;
public void sendVerificationEmail(String email, String token) {
try {
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(email);
message.setSubject("[OnBoarding] 이메일 인증");
message.setText(
"안녕하세요, OnBoarding입니다.\n\n" +
"회원가입을 완료하기 위해 아래 링크를 클릭하여 추가 정보를 입력해주세요:\n\n" +
baseUrl + "/register/complete?token=" + token + "\n\n" +
"이 링크는 24시간 동안 유효합니다.\n" +
"본인이 요청하지 않은 경우 이 이메일을 무시해주세요."
);
emailSender.send(message);
log.info("이메일 인증 메일 발송 완료: {}", email);
} catch (Exception e) {
log.error("이메일 발송 실패: {}", e.getMessage());
throw new RuntimeException("이메일 발송에 실패했습니다.");
}
}
public void sendPasswordResetEmail(String email, String token) {
try {
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(email);
message.setSubject("[OnBoarding] 비밀번호 재설정");
message.setText(
"안녕하세요, OnBoarding입니다.\n\n" +
"비밀번호 재설정을 위해 아래 링크를 클릭해주세요:\n\n" +
baseUrl + "/reset-password?token=" + token + "\n\n" +
"이 링크는 24시간 동안 유효합니다.\n" +
"본인이 요청하지 않은 경우 이 이메일을 무시해주세요."
);
emailSender.send(message);
log.info("비밀번호 재설정 이메일 발송 완료: {}", email);
} catch (Exception e) {
log.error("이메일 발송 실패: {}", e.getMessage());
throw new RuntimeException("이메일 발송에 실패했습니다.");
}
}
}