我正在尝试通过 Oracle 设置 UTL_MAIL 以向用户发送有关帐户停用的电子邮件。以下是我到目前为止所做的 -
Installed the package - @utlmail.sql & @prvtmail.plb
Set smtp parameter - ALTER SYSTEM SET smtp_out_server = 'smtp.mail.com' SCOPE = BOTH;
Completed ACL setup:-
exec DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('utl_mail.xml','Allow mail to be send','SCHEMA', TRUE, 'connect');
commit;
exec DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('utl_mail.xml','SCHEMA', TRUE, 'connect');
exec DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('utl_mail.xml','SCHEMA', TRUE, 'resolve');
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('utl_mail.xml','*',25);
commit;
然后我创建了一个测试程序,看看这一切是否有效
CREATE OR REPLACE PROCEDURE deactivated_email IS
vsender VARCHAR2(30) := 'sender@sender.edu';
vrecip VARCHAR2(30) := 'recip@recip.edu';
vsubj VARCHAR2(50) := 'Enter the subject here';
vmesg VARCHAR2(4000) := 'Enter the body';
vmtype VARCHAR2(30) := 'text/plain; charset=us-ascii';
BEGIN
utl_mail.send(
vsender,
vrecip,
NULL,
NULL,
vsubj,
vmesg,
vmtype,
NULL
);
END;
执行过程
EXECUTE deactivated_email;
收到错误
BEGIN deactivated_email; END;
Error report -
ORA-29279: SMTP permanent error: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [smtp.mail.com]
ORA-06512: at "SYS.UTL_MAIL", line 662
ORA-06512: at "SYS.UTL_MAIL", line 679
ORA-06512: at "DEACTIVATED_EMAIL", line 17
ORA-06512: at line 1
29279. 00000 - "SMTP permanent error: %s"
*Cause: A SMTP permanent error occurred.
*Action: Correct the error and retry the SMTP operation.
我让我们的交换团队为我正在处理的虚拟机打开超过 25 个 smtp,我可以通过 RHEL 主机发送邮件,这样盒子就打开了。我猜 smtp 需要来自 utl_mail 包/oracle 的某种身份验证,但到目前为止我一直无法弄清楚我可以在哪里通过包/oracle 通过此身份验证
任何反馈表示赞赏