Where The Streets Have No Name

pl/sql에서 메일 보내기 본문

Developement/DataBase

pl/sql에서 메일 보내기

highheat 2006. 7. 14. 09:53
CREATE OR REPLACE procedure pr_pv_send_mail
        ( p_from        in      varchar2,
          p_from_name   in      varchar2,
          p_to          in      varchar2,
          p_to_name     in      varchar2,
          p_subject     in      varchar2,
          p_body        in      varchar2 )
is
          v_connection UTL_SMTP.CONNECTION;
          mesg VARCHAR2( 6000 ) := '';
begin
          --smtp setting
          v_connection := UTL_SMTP.OPEN_CONNECTION('156.147.113.6',25);
          UTL_SMTP.HELO(v_connection,'156.147.113.6');
          UTL_SMTP.MAIL(v_connection,p_from);
          UTL_SMTP.RCPT(v_connection,p_to);
          UTL_SMTP.open_data(v_connection);
          mesg := 'From: '|| p_from_name || '<' || p_from || '>' ||utl_tcp.CRLF;
          mesg := mesg||'To: '|| p_to_name || '<'|| p_to || '>' ||utl_tcp.CRLF;
          mesg := mesg||'Subject: '|| p_subject ||utl_tcp.CRLF;
          mesg := mesg||'content-type: text/html;' || chr(13) || chr(10) || p_body||'';
          UTL_SMTP.write_raw_data(v_connection,UTL_RAW.CAST_TO_RAW(mesg));
          UTL_SMTP.close_data(v_connection);
          UTL_SMTP.QUIT(v_connection);
end;
/