Skip to content

Commit

Permalink
[refactor] #6 MailProvider 인자값, 리턴값 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ziiyouth committed Dec 27, 2023
1 parent 028a88d commit 8fa784c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class MemberService {
private final MailProvider mailProvider;

public EmailResponseDto sendMail(EmailPostRequestDto emailPostRequestDto) {
return mailProvider.sendMail(emailPostRequestDto, "email");
String authNum = mailProvider.sendMail(emailPostRequestDto.email(), "email");
return new EmailResponseDto(authNum);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.gachon.checkmate.domain.member.dto.request.EmailPostRequestDto;
import org.gachon.checkmate.domain.member.dto.response.EmailResponseDto;
import org.gachon.checkmate.global.error.exception.InternalServerException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
Expand All @@ -25,16 +24,16 @@ public class MailProvider {
private final JavaMailSender javaMailSender;
private final SpringTemplateEngine templateEngine;

public EmailResponseDto sendMail(EmailPostRequestDto emailPostRequestDto, String type) {
public String sendMail(String email, String type) {
String authNum = createNumericCode();
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
try {
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, false, "UTF-8");
mimeMessageHelper.setTo(emailPostRequestDto.email()); // 메일 수신자
mimeMessageHelper.setTo(email); // 메일 수신자
mimeMessageHelper.setSubject("[CHECKMATE] 이메일 인증번호 발송"); // 메일 제목
mimeMessageHelper.setText(setContext(authNum, type), true); // 메일 본문
javaMailSender.send(mimeMessage);
return new EmailResponseDto(authNum);
return authNum;
} catch (MessagingException e) {
throw new InternalServerException(EMAIL_SEND_ERROR);
}
Expand Down

0 comments on commit 8fa784c

Please sign in to comment.