下面存储过程执行后有错误,
create or replace procedure test_mail(msg_subject in varchar2,
                            mes_context in varchar2,to_user in varchar2) 
                         
is        Mail_Conn Utl_Smtp.Connection;
        Msg       Varchar2(4000);
        Msg_Raw   Raw(32767);
       
        v_User Varchar2(20) :='user';
        v_Pass Varchar2(20) :='pass'; 
        
        v_Mailhost Varchar2(50) := 'stmp.126.com';
        v_Mailport Integer := 25;       
        --邮件发送参数
      
       v_Senduser Varchar2(50) := '[email protected]';
Begin        Msg := 'Date:' || To_Char(Sysdate, 'dd mon yy hh24:mi:ss') || Utl_Tcp.Crlf;
        Msg := Msg || 'From: ' || v_Senduser || '<' || v_Senduser || '>' || Utl_Tcp.Crlf;
        Msg := Msg || 'To: ' || to_user || '<' || to_user || '>' || Utl_Tcp.Crlf;
        Msg := Msg || 'Subject: ' || msg_subject || Utl_Tcp.Crlf || Utl_Tcp.Crlf;
        Msg := Msg || mes_context;        Msg_Raw := Utl_Raw.Cast_To_Raw(Convert(Msg, 'ZHS16GBK'));        Mail_Conn := Utl_Smtp.Open_Connection(v_Mailhost, v_Mailport);
        Utl_Smtp.Helo(Mail_Conn, v_Mailhost);        /* smtp服务器登录校验 */
      -- IF P_NEED_SMTP = 1 THEN        Utl_Smtp.Command(Mail_Conn, 'AUTH LOGIN');
        Utl_Smtp.Command(Mail_Conn, Utl_Raw.Cast_To_Varchar2(Utl_Encode.Base64_Encode(Utl_Raw.Cast_To_Raw(v_User))));
        Utl_Smtp.Command(Mail_Conn, Utl_Raw.Cast_To_Varchar2(Utl_Encode.Base64_Encode(Utl_Raw.Cast_To_Raw(v_Pass))));
      -- end if;
        --发送邮件
        Utl_Smtp.Mail(Mail_Conn, v_Senduser);
        Utl_Smtp.Rcpt(Mail_Conn, to_user);
        Utl_Smtp.Open_Data(Mail_Conn);
        Utl_Smtp.Write_Raw_Data(Mail_Conn, Msg_Raw);
        Utl_Smtp.Close_Data(Mail_Conn);
        Utl_Smtp.Quit(Mail_Conn);Exception
        When Others Then
                Dbms_Output.Put_Line(Dbms_Utility.Format_Error_Stack);
                Dbms_Output.Put_Line(Dbms_Utility.Format_Call_Stack);
                Dbms_Output.Put_Line(Substr(Sqlerrm, 1, 250));
end test_mail;请各位xdjm 帮忙看看?不胜感激。       

解决方案 »

  1.   

    下面为错误信息:
    ORA-29278: SMTP 临时性错误: 421 Service not available----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    c000000673f34418        59  procedure DMUSER.S_MAIL
    c000000673eccf28         1  anonymous blockORA-29278: SMTP 临时性错误: 421 Service not availablePL/SQL procedure successfully completed