Send a letter with Oracle's SMTP

xiaoxiao2021-03-06  20

Create Or Replace Procedure Test

IS

--SMTP and TCP / IP connection information

CONN UTL_SMTP.CONNECTION;

--returned messages

v_reply utl_smtp.reply;

- Send Mail's header information displayed

Procedure send_header (ctx in varchar2) AS

Begin

UTL_SMTP.WRITE_DATA (CONN, CTX || UTL_TCP.CRLF);

END;

Begin

CONN: = UTL_SMTP.OPEN_CONNECTION ('192.100.2.192');

v_reply: = utl_smtp.helo (conn, '192.100.2.192');

DBMS_OUTPUT.PUT_LINE (v_reply.code || 'helo reply' || v_reply.text);

v_reply: = UTL_SMTP.mail (conn, 'guoxh');

DBMS_OUTPUT.PUT_LINE (v_reply.code || 'mail reply' || v_reply.text);

v_reply: = UTL_SMTP.RCPT (CONN, 'GuOxH');

DBMS_OUTPUT.PUT_LINE (v_reply.code || 'RCPT reply' || v_reply.text);

UTL_SMTP.OPEN_DATA (CONN);

--Write Title

DBMS_OUTPUT.PUT_LINE ('Write Title');

Send_header ('from: master');

Send_header ('to: "guoxh"

Send_header ('Subject: DB Info');

- Write Mail Content

DBMS_OUTPUT.PUT_LINE ('Write Mail Content');

- Support Chinese Send

UTL_SMTP.WRITE_RAW_DATA (CONN, UTL_RAW.CAST_TO_RAW (UTL_TCP.CRLF || 'Hi, I''m Coming from The Oracle9i China '));

--UTL_SMTP.WRITE_DATA (CONN, UTL_TCP.CRLF || 'Hi, I''m Coming from The Oracle9i China ');

--Close Connect

UTL_SMTP.CLOSE_DATA (CONN);

UTL_smtp.quit (conn);

EXCEPTION

WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN

Begin

DBMS_OUTPUT.PUT_LINE ('SMTP Error:' || SQlerRM);

UTL_smtp.quit (conn);

EXCEPTION

When Others Then

DBMS_OUTPUT.PUT_LINE ('Other Error');

END;

When Others Then

NULL;

End test;

转载请注明原文地址:https://www.9cbs.com/read-43197.html

New Post(0)