<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>WooriMail on YuuuuuuYu</title><link>https://4d4cat.com/tags/woorimail/</link><description>Recent content in WooriMail on YuuuuuuYu</description><generator>Hugo -- 0.147.2</generator><language>ko-KR</language><lastBuildDate>Tue, 26 Aug 2025 16:33:46 +0900</lastBuildDate><atom:link href="https://4d4cat.com/tags/woorimail/index.xml" rel="self" type="application/rss+xml"/><item><title>우리메일 API를 이용한 배치 스크립트</title><link>https://4d4cat.com/posts/2024/woorimail-api/</link><pubDate>Wed, 12 Jun 2024 14:44:00 +0900</pubDate><guid>https://4d4cat.com/posts/2024/woorimail-api/</guid><description>&lt;pre tabindex="0">&lt;code>#!/bin/bash
######### NOTICE ##############
# Itsm 요청이 왔을 때
# 메일 발송되는 것이 목적이라서
# 아래 소스는 ChatGPT로
# 최소한의 로직만 구현했습니다
###############################
######## MAIL API ############
# 우리메일(WOORIMAIL)
# https://woorimail.com
#
# 월 1만건 무료 발송 가능합니다
# 메일 1만건 모두 소진 시
# 당월 메일 발송이 중지됩니다
##############################
###### TIME SETTING ###########
# 현재 9시 ~ 18시까지만
# 동작하도록 세팅되어있으니
# 수정이 필요하면 아래 함수에서
# 시간 수정 부탁드립니다
# check_working_hours()
###############################
##### RECEIVER INFO ###########
# 메일 발신자 정보 수정은
# 60번 줄 영역에 있는 값을
# 수정해주시면 됩니다
###############################
# Function to make API call and check response
check_response() {
# API details
METHOD=&amp;#34;POST&amp;#34;
CONTENT_TYPE=&amp;#34;application/x-www-form-urlencoded&amp;#34;
ITSM_CHECK_URL=&amp;#34;&amp;#34; # ITSM 접수대기 건수 URL
ITSM_LIST_URL=&amp;#34;&amp;#34; # ITSM 접수대기 리스트 URL
BODY=&amp;#34;id=1520&amp;#34; # 접수대기(1520), 처리중(1526)
# ITSM 처리중
#ITSM_LIST_URL=&amp;#34;&amp;#34;
#BODY=&amp;#34;id=1526&amp;#34;
# 고정값
MAIL_URL=&amp;#34;https://woorimail.com/&amp;#34;
TYPE=&amp;#34;api&amp;#34;
MID=&amp;#34;auth_woorimail&amp;#34;
ACT=&amp;#34;dispWwapimanagerMailApi&amp;#34;
DOMAIN=&amp;#34;&amp;#34; # 지정한 도메인 URL
AUTHKEY=&amp;#34;&amp;#34; # 키값
##################################################
# 아래처럼 세팅했을 경우 메일은 다음과 같이 발송됩니다
#
# 발신자: YuY&amp;lt;wms_nick@mx.woorimail.com&amp;gt;
# 회신할 경우, 받는사람: ID@이메일주소
##################################################
WMS_NICK=&amp;#34;wms_nick&amp;#34; # 보낸사람 계정
SENDER_EMAIL=&amp;#34;&amp;#34; # 회신할 사람 이메일
SENDER_NICKNAME=&amp;#34;YuY&amp;#34; # 회신할 사람 닉네임
RECEIVER_NICKNAME=&amp;#34;&amp;#34; # 받는 사람(나) 닉네임
RECEIVER_EMAIL=$RECEIVER_EMAIL # 받는 사람(나) 이메일
# Add cookies to the request
COOKIE=&amp;#34;JSESSIONID=$JSESSIONID&amp;#34; # ITSM JSessionID 값
# Make the API call and print the response
RESPONSE=$(curl -s -X $METHOD \
-H &amp;#34;Content-Type: $CONTENT_TYPE&amp;#34; \
-H &amp;#34;Cookie: $COOKIE&amp;#34; \
-d &amp;#34;$BODY&amp;#34; \
$ITSM_CHECK_URL)
# Extract result value from RESPONSE message
RESULT_ITSM_READY_CNT=$(echo &amp;#34;$RESPONSE&amp;#34; | grep -oP &amp;#39;result: \(\K[0-9]+&amp;#39;)
# Check if RESULT is greater than 0 and show dialog
if validate_email &amp;#34;$RECEIVER_EMAIL&amp;#34;; then
if [ &amp;#34;$RESULT_ITSM_READY_CNT&amp;#34; -gt 0 ]; then
RESPONSE=$(curl -s -X $METHOD \
-H &amp;#34;Content-Type: $CONTENT_TYPE&amp;#34; \
-H &amp;#34;Cookie: $COOKIE&amp;#34; \
-d &amp;#34;$BODY&amp;#34; \
$ITSM_LIST_URL)
RESULT_ITSM_READY_LIST=$(echo &amp;#34;$RESPONSE&amp;#34; | sed -n &amp;#39;/&amp;lt;table width=&amp;#34;100%&amp;#34;/,/&amp;lt;\/table&amp;gt;/p&amp;#39; | sed -n &amp;#39;1,/&amp;lt;\/table&amp;gt;/p&amp;#39; | grep -o &amp;#39;&amp;lt;td[^&amp;gt;]*&amp;gt;[^&amp;lt;]*&amp;lt;/td&amp;gt;&amp;#39; | sed -E &amp;#39;s/&amp;lt;\/?td[^&amp;gt;]*&amp;gt;//g&amp;#39;)
RESULT_ITSM_ALL_HTML=$(echo &amp;#34;$RESPONSE&amp;#34; | sed &amp;#39;:a;N;$!ba;s/\n/ /g&amp;#39; | grep -oP &amp;#39;&amp;lt;table width=&amp;#34;100%&amp;#34;.*?&amp;lt;/table&amp;gt;&amp;#39;)
# Convert the multiline string to an array
IFS=$&amp;#39;\n&amp;#39; read -r -d &amp;#39;&amp;#39; -a TD_VALUES_ARRAY &amp;lt;&amp;lt;&amp;lt; &amp;#34;$RESULT_ITSM_READY_LIST&amp;#34;
MAIL_TITLE=&amp;#34;ITSM &amp;#34;
# Process the array in chunks of 7
num_values=${#TD_VALUES_ARRAY[@]}
for ((i = 0; i &amp;lt; num_values; i += 7)); do
MAIL_TITLE=&amp;#34;$MAIL_TITLE ${TD_VALUES_ARRAY[i]} &amp;#34;
done
MAIL_TITLE=$(url_encode &amp;#34;$MAIL_TITLE&amp;#34;)
MAIL_CONTENT=$(url_encode &amp;#34;ITSM 대기건수: $RESULT_ITSM_READY_CNT 건 $RESULT_ITSM_ALL_HTML&amp;#34;)
MAIL_BODY=&amp;#34;authkey=$AUTHKEY&amp;amp;domain=$DOMAIN&amp;amp;type=$TYPE&amp;amp;mid=$MID&amp;amp;act=$ACT&amp;amp;callback=&amp;amp;title=$MAIL_TITLE&amp;amp;content=$MAIL_CONTENT&amp;amp;wms_domain=woorimail.com&amp;amp;wms_nick=$WMS_NICK&amp;amp;sender_email=$SENDER_EMAIL&amp;amp;sender_nickname=$SENDER_NICKNAME&amp;amp;receiver_nickname=$RECEIVER_NICKNAME&amp;amp;receiver_email=$RECEIVER_EMAIL&amp;amp;member_regdate=20240604170101&amp;#34;
RESPONSE=$(curl -s -X $METHOD \
-H &amp;#34;Content-Type: $CONTENT_TYPE&amp;#34; \
-d &amp;#34;$MAIL_BODY&amp;#34; \
$MAIL_URL)
echo &amp;#34;Ready Itsm: $RESULT_ITSM_READY_CNT, $RESPONSE&amp;#34;
else
echo &amp;#34;Empty Itsm.&amp;#34;
fi
else
echo &amp;#34;Invalid email format. Please provide a valid email address.&amp;#34;
fi
}
# Function to check if current time is within working hours
check_working_hours() {
current_hour=$(date +%H)
if [ &amp;#34;$current_hour&amp;#34; -ge 9 ] &amp;amp;&amp;amp; [ &amp;#34;$current_hour&amp;#34; -lt 18 ]; then
return 0 # Within working hours
else
return 1 # Outside working hours
fi
}
# Function to validate email format
validate_email() {
# Regular expression for email validation
regex=&amp;#39;^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}$&amp;#39;
if [[ $1 =~ $regex ]]; then
return 0 # Valid email format
else
return 1 # Invalid email format
fi
}
# Function to URL encode a string
url_encode() {
local string=&amp;#34;${1}&amp;#34;
local encoded=&amp;#34;&amp;#34;
# Convert the string to hex representation
hex_string=$(echo -n &amp;#34;$string&amp;#34; | od -An -tx1 | tr &amp;#39; &amp;#39; &amp;#39;\n&amp;#39; | grep -v &amp;#39;^$&amp;#39;)
# Iterate over each character in the hex string
for hex_char in $hex_string; do
encoded+=&amp;#34;%$hex_char&amp;#34;
done
echo &amp;#34;$encoded&amp;#34;
}
INTRODUCTION=&amp;#34;
################################################
###### ITSM 로그인 후
###### 쿠키에 등록된 JSESSIONID 값을 입력해주세요
################################################
################################################
# 입력 파라미터, 몇분마다 이메일로 발송할지 세팅
# 1: 시간, 분(minute)
# 2: 이메일 주소
#
# ex) ./checkItsm.sh 5 이메일주소
# -&amp;gt; 5분마다 접수대기 중인 itsm을 체크하여
# -&amp;gt; 1건 이상 있을 경우 입력한 이메일로 발송
#
# Itsm이 장시간으로 접수대기 상태인 경우가 많을수록
# 시간을 길게 세팅하는게 좋습니다
# 권장 시간(분) 5 ~ 20
################################################
값을 제대로 입력하면 아래와 같은 형식의 문구가 나옵니다
- 접수대기 건수가 없는 경우
&amp;gt; Empty Itsm.
- 접수대기 건수가 있는 경우, 메일 발송
&amp;gt; Ready Itsm: 1, result: ~~, error_msg: ~~ ...
JSESSIONID: &amp;#34;
# Prompt user to input JSESSIONID
read -p &amp;#34;$INTRODUCTION&amp;#34; JSESSIONID
# Check if the second argument is provided
if [ -z &amp;#34;$2&amp;#34; ]; then
echo &amp;#34;Please provide a RECEIVER_EMAIL as the second argument.&amp;#34;
exit 1
else
RECEIVER_EMAIL=&amp;#34;$2&amp;#34;
fi
# Check if argument is provided for interval, default is set to 5 minutes
interval=${1:-5}
# Loop indefinitely and check response every $interval minutes
while true; do
# Check if current time is within working hours
if ! check_working_hours; then
echo &amp;#34;Outside working hours. Exiting...&amp;#34;
exit 0
fi
check_response
sleep &amp;#34;$interval&amp;#34;m
done
&lt;/code>&lt;/pre></description></item></channel></rss>