PROCEDURE MAIL_SEND( P_FROM VARCHAR2,
P_TO VARCHAR2,
P_SUBJECT VARCHAR2,
P_MESSAGE VARCHAR2)
IS
V_SERVER VARCHAR2(255) := '메일서버IP';
V_CONN UTL_SMTP.CONNECTION;
BEGIN
V_CONN := UTL_SMTP.Open_Connection(V_SERVER);
UTL_SMTP.Helo(V_CONN, V_SERVER);
UTL_SMTP.Mail(V_CONN, P_FROM);
UTL_SMTP.Rcpt(V_CONN, P_TO);
UTL_SMTP.OPEN_DATA(V_CONN);
UTL_SMTP.WRITE_DATA(V_CONN, 'Subject: =?UTF-8?B?' ||
UTL_RAW.CAST_TO_VARCHAR2(UTL_ENCODE.BASE64_ENCODE(UTL_RAW.CAST_TO_RAW(P_SUBJECT))) ||
'?=' || UTL_TCP.CRLF);
/*UTL_SMTP.WRITE_DATA(V_CONN, 'Subject: =?UTF-8?Q?' ||
UTL_RAW.CAST_TO_VARCHAR2(UTL_ENCODE.QUOTED_PRINTABLE_ENCODE(UTL_RAW.CAST_TO_RAW(P_SUBJECT))) ||
'?=' || UTL_TCP.CRLF);*/
UTL_SMTP.WRITE_DATA(V_CONN, 'MIME-version: 1.0' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(V_CONN, 'Content-Type: text/html;charset=utf-8' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(V_CONN, 'Content-Transfer-Encoding: quoted-printable '|| UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(V_CONN, 'Date: ' || TO_CHAR(SYSDATE, 'dd Mon yy hh24:mi:ss' ) ||' -0800 (GMT)' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(V_CONN, 'From: ' || P_FROM || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(V_CONN, 'To: ' || P_TO || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(V_CONN, UTL_TCP.CRLF);
UTL_SMTP.WRITE_RAW_DATA(V_CONN, UTL_ENCODE.QUOTED_PRINTABLE_ENCODE(UTL_RAW.CAST_TO_RAW(P_MESSAGE)));
UTL_SMTP.WRITE_DATA(V_CONN, UTL_TCP.CRLF);
UTL_SMTP.CLOSE_DATA(V_CONN);
UTL_SMTP.QUIT(V_CONN);
RETURN;
END MAIL_SEND;