调用发送邮件过程后发生错误

时间:2019-02-20 05:14:15

标签: oracle oracle11g oracle-sqldeveloper oracle-apex oracle-apex-5

我已经在下面编写的sql developer oracle中创建了一个名为send_mail的过程。

create or replace procedure Send_Mail(Msg_To varchar2, Msg_Subject varchar2, Msg_Text varchar2) is

    c        Utl_Smtp.Connection;
    Rc       integer;
    Msg_From varchar2(50) := 'it.dev23@dawateislami.net'; -- email of my company which hosted on Gmail
    Mailhost varchar2(30) := 'smtp.gmail.com';


begin
    c := Utl_Smtp.Open_Connection(Mailhost, 587);
    Utl_Smtp.Ehlo(c, Mailhost);
    Utl_Smtp.StartTLS(c);
    Utl_Smtp.Ehlo(c, Mailhost);
    Utl_Smtp.Mail(c, Msg_From);
    Utl_Smtp.Rcpt(c, Msg_To);

    Utl_Smtp.Data(c,
                  'From: Oracle Database' || Utl_Tcp.Crlf || 'To: ' || Msg_To || Utl_Tcp.Crlf || 'Subject: ' || Msg_Subject || Utl_Tcp.Crlf ||
                  Msg_Text);
    Utl_Smtp.Quit(c);

exception
    when Utl_Smtp.Invalid_Operation then
        Dbms_Output.Put_Line(' Invalid Operation in Mail attempt 
using UTL_SMTP.');
    when Utl_Smtp.Transient_Error then
        Dbms_Output.Put_Line(' Temporary e-mail issue - try again');
    when Utl_Smtp.Permanent_Error then
        Dbms_Output.Put_Line(' Permanent Error Encountered.');
end;

当我尝试调用该过程以发送电子邮件时,它给出了错误,请帮助我,我想发送电子邮件。让我知道我的错误在哪里。 我已经授予所有命令

GRANT EXECUTE ON UTL_TCP  TO admonline;
GRANT EXECUTE ON UTL_SMTP TO admonline;
GRANT EXECUTE ON UTL_MAIL TO admonline;
GRANT EXECUTE ON UTL_http TO admonline;
--Calling procedure
BEGIN
send_mail(msg_to      => 'waqasprince911@gmail.com',
          msg_subject => 'Test subject',
          msg_text    => 'Test text');
END;   

错误是提及

 Certificate validation failure
    ORA-06512: at "SYS.UTL_TCP", line 59
    ORA-06512: at "SYS.UTL_TCP", line 284
    ORA-06512: at "SYS.UTL_SMTP", line 284
    ORA-06512: at "SYS.UTL_SMTP", line 289
    ORA-06512: at "ADMONLINE.SEND_MAIL", line 11
    ORA-06512: at line 2
    29024. 00000 -  "Certificate validation failure"

    *Cause:    The certificate sent by the other side could not be validated. This may occur if
               the certificate has expired, has been revoked, or is invalid for another reason.

    *Action:   Check the certificate to determine whether it is valid. Obtain a new certificate,
               alert the sender that the certificate has failed, or resend.

1 个答案:

答案 0 :(得分:0)

错误似乎很明显。尝试对UTL_SMTP,证书和29024进行googliing。00000-“证书验证失败”也请阅读有关如何使用此软件包的文档。这似乎是安全证书的失败。

一个快速的Google出现了this

另外,作为菜鸟,请记住您是在要求我们抽出时间来帮助您。始终提供产品的版本,您尝试过的步骤,结果以及您尝试过的搜索和调查,为我们提供帮助。

这些可能有助于: https://mathijsbruggink.com/2013/10/24/sending-mail-from-an-11g-oracle-database-utl_smtp/ https://community.oracle.com/thread/930797 http://www.dadbm.com/enable-oracle-database-to-send-emails-via-smtp-server/ https://community.oracle.com/thread/368259

https://community.oracle.com/thread/4089002 https://oracle-base.com/articles/misc/utl_http-and-ssl

https://docs.oracle.com/database/121/ARPLS/u_smtp.htm#ARPLS074 https://oracle-base.com/articles/misc/email-from-oracle-plsql