CREATE OR REPLACE procedure proc_utl_smtp_mail (p_from IN varchar2,
p_to IN varchar2,
p_subject IN VARCHAR2,
p_cc IN VARCHAR2 DEFAULT NULL,
p_mailhost VARCHAR2)
IS
l_message Long;
l_return_status VARCHAR2(10);
l_return_msg VARCHAR2(1000);
l_reply UTL_SMTP.reply;
l_smtp_port NUMBER := 25;
l_mail_con UTL_SMTP.CONNECTION;
l_crlf VARCHAR2(100):= chr(13) || chr(10);
l_cnt NUMBER;
BEGIN
l_message := 'Testing Procedure for UTL_SMTP Mail Package.';
l_mail_con := SYS.utl_smtp.open_connection (p_mailhost,l_smtp_port);
UTL_SMTP.helo (l_mail_con,p_mailhost);
utl_smtp.mail (l_mail_con,p_from);
utl_smtp.rcpt (l_mail_con,p_to);
utl_smtp.rcpt (l_mail_con,p_cc);
utl_smtp.open_data (l_mail_con);
utl_smtp.write_data (l_mail_con, 'TO:' ||p_from || l_CRLF);
utl_smtp.write_data (l_mail_con, 'SUBJECT:' ||p_subject || l_CRLF);
utl_smtp.write_data (l_mail_con , 'X-Priority :' || '1' || l_crlf); --- To Send Mails as High Priority
utl_smtp.write_data (l_mail_con, l_crlf
|| 'Mr. XXXX'
|| l_crlf
|| l_crlf
|| 'Subject: '
|| p_subject
|| l_crlf
|| l_crlf
|| 'Message : '
|| l_message
|| l_crlf
|| l_crlf
|| ' Do Not reply this message.'
|| l_crlf
|| 'Thanks & Rgards'
|| l_crlf
|| 'Oracle Team'
);
utl_smtp.close_data (l_mail_con);
l_reply := UTL_SMTP.QUIT (l_mail_con);
dbms_output.put_line ('l_reply :' || l_reply.text);
END;
/
p_to IN varchar2,
p_subject IN VARCHAR2,
p_cc IN VARCHAR2 DEFAULT NULL,
p_mailhost VARCHAR2)
IS
l_message Long;
l_return_status VARCHAR2(10);
l_return_msg VARCHAR2(1000);
l_reply UTL_SMTP.reply;
l_smtp_port NUMBER := 25;
l_mail_con UTL_SMTP.CONNECTION;
l_crlf VARCHAR2(100):= chr(13) || chr(10);
l_cnt NUMBER;
BEGIN
l_message := 'Testing Procedure for UTL_SMTP Mail Package.';
l_mail_con := SYS.utl_smtp.open_connection (p_mailhost,l_smtp_port);
UTL_SMTP.helo (l_mail_con,p_mailhost);
utl_smtp.mail (l_mail_con,p_from);
utl_smtp.rcpt (l_mail_con,p_to);
utl_smtp.rcpt (l_mail_con,p_cc);
utl_smtp.open_data (l_mail_con);
utl_smtp.write_data (l_mail_con, 'TO:' ||p_from || l_CRLF);
utl_smtp.write_data (l_mail_con, 'SUBJECT:' ||p_subject || l_CRLF);
utl_smtp.write_data (l_mail_con , 'X-Priority :' || '1' || l_crlf); --- To Send Mails as High Priority
utl_smtp.write_data (l_mail_con, l_crlf
|| 'Mr. XXXX'
|| l_crlf
|| l_crlf
|| 'Subject: '
|| p_subject
|| l_crlf
|| l_crlf
|| 'Message : '
|| l_message
|| l_crlf
|| l_crlf
|| ' Do Not reply this message.'
|| l_crlf
|| 'Thanks & Rgards'
|| l_crlf
|| 'Oracle Team'
);
utl_smtp.close_data (l_mail_con);
l_reply := UTL_SMTP.QUIT (l_mail_con);
dbms_output.put_line ('l_reply :' || l_reply.text);
END;
/