Gmail 在Oracle Linux 7上从Oracle 12c发送带有后缀的电子邮件
我在我的Oracle Linux上有后缀服务,它们工作得很好。 我使用函数Gmail 在Oracle Linux 7上从Oracle 12c发送带有后缀的电子邮件,gmail,oracle12c,rhel7,postfix,Gmail,Oracle12c,Rhel7,Postfix,我在我的Oracle Linux上有后缀服务,它们工作得很好。 我使用函数 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) := 'me@me.com'; -- email of my
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) := 'me@me.com'; -- email of my company which hosted on Gmail
Mailhost varchar2(30) := 'smtp.gmail.com';
begin
c := Utl_Smtp.Open_Connection(Mailhost, 587);
Utl_Smtp.Helo(c, Mailhost);
Utl_Smtp.StartTLS(c);
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;
我在上面找到的
当我运行函数时
BEGIN
send_mail(msg_to => 'me@me.com',
msg_subject => 'Test subject',
msg_text => 'Test text');
END;
我得到一个错误:
ORA-29279: SMTP permanent error: 530 5.7.0 Must issue a STARTTLS command first. im3sm2477330wjb.13 - gsmtp /* 132/5 selected symbols */
我做错了什么或者我必须做什么?文档中提到了错误,文档中也告诉了您。您需要调用
utl\u smtp.starttls()
谢谢你,@AlexPoole,但现在是ORA-29279:SMTP永久性错误:503 5.5.1 EHLO/HELO。r7sm3173844wjp.43-gsmtpOK,所以先调用
ehlo
。文档还说,您需要在以后重新发布,尽管他们的示例没有这样做。您可能需要为open_connection
调用提供更多参数,如文档中所示。我重写了相关代码,现在有了,PLS-00905:object SYS.SEND_MAIL无效/*;=#59*/请不要将问题编辑为不再显示您最初询问的错误的内容。您不应该在SYS模式或任何其他内置模式中创建过程。您可以显示错误
或查询用户错误
视图,查看该过程的错误。但是您似乎发明了一个utl\u smtp.set\u wallet
过程,而不是使用open\u connection()
中的参数?对不起,我的错误是utl\u http.set\u wallet,现在是ORA-29024:证书验证失败
...
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);
...