Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Oracle send email]
DECLARE
v_mail_conn utl_smtp.connection;
v_boundary varchar2(50) := '----=*#abc1234321cba#*=';
v_step pls_integer := 24573;
v_env varchar2(5);
v_mail_server varchar2(64) := 'bulkmailrelay.ucs.ed.ac.uk';
v_from varchar2(100) := 'john.chan@ed.ac.uk';
BEGIN
v_mail_conn := utl_smtp.open_connection(v_mail_server, 25);
utl_smtp.helo(v_mail_conn, v_mail_server);
UTL_SMTP.mail(v_mail_conn, v_from);
UTL_SMTP.rcpt(v_mail_conn, 'john.chan@ed.ac.uk');
UTL_SMTP.open_data(v_mail_conn);
-- UTL_SMTP.write_data(v_mail_conn, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || UTL_TCP.crlf);
UTL_SMTP.write_data(v_mail_conn, 'Date: ' || TO_CHAR(SYSTIMESTAMP, 'Dy, dd Mon yyyy hh24:mi:ss tzhtzm') || UTL_TCP.crlf); --HRS073 JIRA https://www.jira.is.ed.ac.uk/jira/browse/HRS073-22
UTL_SMTP.write_data(v_mail_conn, 'To: ' || 'john.chan@ed.ac.uk' || UTL_TCP.crlf);
UTL_SMTP.write_data(v_mail_conn, 'From: ' || v_from || UTL_TCP.crlf);
UTL_SMTP.write_data(v_mail_conn, 'Subject: ' || 'TEST PLEASE IGNORE ERECRUITMENT DEBUG ' || UTL_TCP.crlf);
UTL_SMTP.write_data(v_mail_conn, 'Reply-To: ' || v_from || UTL_TCP.crlf);
UTL_SMTP.write_data(v_mail_conn, 'MIME-Version: 1.0' || UTL_TCP.crlf);
UTL_SMTP.write_data(v_mail_conn, 'Content-Type: multipart/mixed; boundary="' || v_boundary || '"' || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.write_data(v_mail_conn, '--' || v_boundary || UTL_TCP.crlf);
UTL_SMTP.write_data(v_mail_conn, 'Content-Type: text/plain; charset="iso-8859-1"' || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.WRITE_DATA(v_mail_conn, UTL_TCP.CRLF || UTL_TCP.CRLF || 'This is an automatically generated email, please do not reply.');
UTL_SMTP.CLOSE_DATA(v_mail_conn);
UTL_SMTP.QUIT(v_mail_conn);
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.