CREATE OR REPLACE
PROCEDURE send_email_html (str_to IN VARCHAR2,
str_subject IN VARCHAR2,
IS
l_mail_conn UTL_SMTP.connection;
BEGIN
l_mail_conn := UTL_SMTP.open_connection ('10.10.10.10', 25);
UTL_SMTP.helo (l_mail_conn, '10.10.10.10');
UTL_SMTP.command (l_mail_conn, 'AUTH LOGIN');
UTL_SMTP.command (
l_mail_conn,
UTL_RAW.cast_to_varchar2 (
UTL_ENCODE.base64_encode (UTL_RAW.cast_to_raw ('test'))));
UTL_SMTP.command (
l_mail_conn,
UTL_RAW.cast_to_varchar2 (
UTL_ENCODE.base64_encode (UTL_RAW.cast_to_raw ('abcd%1234'))));
UTL_SMTP.mail (l_mail_conn, 'test@xxx.com');
UTL_SMTP.rcpt (l_mail_conn, str_to);
UTL_SMTP.open_data (l_mail_conn);
UTL_SMTP.write_data (
l_mail_conn,
'Subject: =?UTF-8?Q?'
|| UTL_RAW.cast_to_varchar2(UTL_ENCODE.quoted_printable_encode (
UTL_RAW.cast_to_raw (str_subject)))
|| '?='
|| UTL_TCP.crlf);
UTL_SMTP.write_data (l_mail_conn, 'MIME-version: 1.0' || UTL_TCP.crlf);
UTL_SMTP.write_data (
l_mail_conn,
'Content-Type: text/html;charset=utf-8' || UTL_TCP.crlf);
UTL_SMTP.write_data (
l_mail_conn,
'Content-Transfer-Encoding: quoted-printable ' || UTL_TCP.crlf);
UTL_SMTP.write_data (
l_mail_conn,
'Date: '
|| TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS')
|| UTL_TCP.crlf);
UTL_SMTP.write_data (l_mail_conn, 'To: ' || str_to || UTL_TCP.crlf);
UTL_SMTP.write_data (
l_mail_conn,
'From: ' || 'SystemAlerter@xxx.com' || UTL_TCP.crlf);
UTL_SMTP.write_data (
l_mail_conn,
'Reply-To: '
|| 'test@xxx.com'
|| UTL_TCP.crlf
|| UTL_TCP.crlf);
UTL_SMTP.write_raw_data (
l_mail_conn,
UTL_ENCODE.quoted_printable_encode (UTL_RAW.cast_to_raw (str_body)));
UTL_SMTP.close_data (l_mail_conn);
UTL_SMTP.quit (l_mail_conn);
END send_email_html;
/