CREATE OR REPLACE FUNCTION TEST_SMTP_MAIL RETURN TSTRINGS PIPELINED IS
------------------------------
-- Usage: SELECT column_value as LINE from table(TEST_SMTP_MAIL);
------------------------------
v_server VARCHAR2(100);
v_port INTEGER;
v_smtp UTL_SMTP.connection;
v_reply UTL_SMTP.reply;
BEGIN
v_server := '10.20.30.40';
v_port := 25;
-- attempt to connect to mail server
pipe row( 'connecting to server '||v_server||' on port: '||v_port||'/tcp' );
v_reply := UTL_SMTP.open_connection( host=>v_server, port=>v_port, c=>v_smtp );
pipe row( 'Reply Code: '||v_reply.code||'. 'Reply Text: '|| reply.text );
-- if a successful connect, gracefully disconnect
if v_reply.code < 400 then
v_reply := UTL_SMTP.quit( smtp );
pipe row( 'Reply Code: '||v_reply.code||'. 'Reply Text: '|| reply.text );
end if;
END TEST_SMTP_MAIL;
/
No comments:
Post a Comment