이메일 알림 발송 계정
띄어쓰기가 포함된 앱 비밀번호
이메일 알림 기능에 사용되는 계정의 비밀번호에 띄어쓰기가 포함되어 있어 CICD 파이프라인에서 에러가 발생하는 문제가 있었다. 구글에서 띄어쓰기를 포함한 비밀번호를 발급했으나, 이를 제외해도 인증이 가능한지 확인해보고자 했다. 현재 시나리오로 먼저 테스트를 진행했으나, 인증에 실패하는 상황이 발생했다
인증 실패 응답
org.springframework.mail.MailAuthenticationException: Authentication failed at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:402) ~[spring-context-support-6.1.16.jar:6.1.16]
최근 설정 서버의 변경 사항이 많았기 때문에 코드가 정상 작동하는지 점검했다. 별다른 문제는 보이지 않았다. 혹시 계정 자체에 문제가 생겼나 싶어 접속 후 알림과 메일을 확인했지만 이상은 없었다.
SMTP 서버 테스트를 할 수 있는 서비스를 발견해 테스트해본 결과, 에러 메시지가 반환되었다. 이를 통해 문제가 내 환경에의 문제가 아니라는 점을 확인할 수 있었다.
{
"success": 0,
"result": {
"code": "EAUTH",
"response": "534-5.7.9 Please log in with your web browser and then try again. For more\n534-5.7.9 information, go to\n534 5.7.9 https://support.google.com/mail/?p=WebLoginRequired 2adb3069b0e04-5439af0e7e6sm2227220e87.66 - gsmtp",
"responseCode": 534,
"command": "AUTH PLAIN"
}
}
의문의 해결
비밀번호를 재설정했음에도 문제가 해결되지 않았다. “보안 수준이 낮은 앱” 옵션 설정으로 문제를 해결했다는 사례를 발견했으나, 해당 옵션은 이미 사라져 있었다. 검색을 이어가던 중, 2025년 1월부터 IMAP 사용 옵션이 사라지는 업데이트가 있었다는 사실을 알게 되었다. 혹시 관련 문제인지 의심하며 다음 날 다시 확인해보았는데, 이유를 알 수 없게도 정상적으로 통신이 이루어졌다. IMAP 관련 옵션이 다시 활성화된 것을 확인했다. 임시적으로 계정이 잠겼던 것일지도 모르지만, 확실한 원인은 알 수 없었다.
{
"success": 1,
"result": {
"accepted": [
"jisuyang@kakao.com"
],
"rejected": [],
"envelopeTime": 89,
"messageTime": 491,
"messageSize": 715,
"response": "250 2.0.0 OK 1737600167 38308e7fff4ca-3072a4ed467sm28731151fa.83 - gsmtp",
"envelope": {
"from": "app.server.client@gmail.com",
"to": [
"jisuyang@kakao.com"
]
},
"messageId": ""
}
}
시퀀스 다이어그램
툴 고르기
최종 발표 자료를 준비하던 중, 시퀀스 다이어그램이 있으면 좋겠다는 의견이 나왔다. 다이어그램을 그려본 적은 없었으나, 도전해보기로 했다. 직접 배치와 모양 설정을 하는 방식은 너무 시간이 많이 소요될 것 같아서, 코드로 다이어그램을 작성할 수 있는 PlantUML Editor를 발견하고 사용하기로 했다.
코드로 작성한 시퀀스 다이어그램
@startuml
hide footbox
actor "웨이팅, 알림 서버" as Server
actor "관리자" as Developer
participant "알림 컨트롤러" as Controller
participant "카프카 리스너" as Listener
participant "이벤트 서비스" as EventService
participant "고객 서버" as CustomerServer
participant "레스토랑 서버" as RestaurantServer
participant "템플릿 컨버터 서비스" as TemplateConverterService
participant "템플릿 서비스" as TemplateService
participant "슬랙 서비스 (알림 서버)" as SlackService
participant "슬랙 서버" as SlackServer
participant "이메일 서비스" as EmailService
participant "히스토리" as History
alt REST API
Developer -> Controller
Controller -> EventService
activate EventService
else Kafka Broker
Server -> Listener: 이벤트 수신
Listener -> EventService
end
group 통합 프로세스
EventService -> CustomerServer: 고객 연락처 조회 API
CustomerServer --> EventService
EventService -> RestaurantServer: 레스토랑 연락처 조회 API
RestaurantServer --> EventService
EventService -> TemplateService: 알림 템플릿 DB 조회
TemplateService --> EventService
EventService -> TemplateConverterService: 데이터 템플릿 바인딩
TemplateConverterService --> EventService
EventService -> History: 알림 히스토리 생성
History --> EventService
EventService -> SlackService: 슬랙 메시지 전송
activate SlackService
SlackService -> SlackServer: Slack API
SlackServer --> SlackService
SlackService --> EventService
deactivate SlackService
end
alt 전송 성공 시
EventService -> History: 알림 발송 상태 업데이트
History --> EventService
else 전송 실패 시
EventService -> EmailService: 이메일 전송
EmailService --> EventService
EventService -> History: 알림 발송 상태 업데이트
History --> EventService
deactivate EventService
end
@enduml
PlantUML 문법 및 기능 을 참고하여 빠르게 작성할 수 있었다. 생각보다 러닝커브가 낮아 큰 고민 없이 진행할 수 있었고, 결과물에 만족감을 느꼈다.