String key = String.valueOf((int) (Math.random() * 900000) + 100000);
String emailBody = String.format("안녕하세요. LooKids 입니다.\\n인증코드는  %s 입니다. 감사합니다.", key);
@Override
	public KeyResponseDto sendSimpleEmail(String to) {
		SimpleMailMessage message = new SimpleMailMessage();
		String subject = "안녕하세요. LooKids 인증번호 입력해주세요.";
		// 서비스로직에 전달할 6자리 랜덤 정수 인증코드와 응답 메세지 셍성
		String key = String.valueOf((int) (Math.random() * 900000) + 100000);
		String emailBody = String.format("안녕하세요. LooKids 입니다.\\n인증코드는  %s 입니다. 감사합니다.", key);

		message.setTo(to);
		message.setSubject(subject);
		message.setText(emailBody);
		try {
			mailSender.send(message);
			log.info("Email sent to: {}", to);
		} catch (MailSendException e) {
			log.error("Failed to send email to: {}", to, e);
			throw new BaseException(BaseResponseStatus.MESSAGE_SEND_FAILED); // BaseException 발생
		}
		return KeyResponseDto.builder()
			.verification(true)
			.build();
	}

→ 이메일 발송이 되며 그 내용에는 인증코드가 포함되며, 새롭게 다시 요청했을때는 값이 재설정된다.

트러블 이슈

email 인증코드 처리에 대해서 정상적으로 이루어지지만

But

다시 RefreshToken 형변환 오류가 발생, 이를 위해 new GenericJackson2JsonRedisSerializer() 를 통한 역직렬화 처리(역직렬화: Redis에서 값을 가져오는 과정, redis에 저장된 데이터를 원래의 자바 객체로 복원)

template.setValueSerializer(new GenericJackson2JsonRedisSerializer()); // Redis의 값을 String 객체로 직렬화