ORA-24247: network access denied by access control list (ACL) while sending email oracle

耗尽温柔 提交于 2019-12-02 01:36:40

You don't need any commit, since explicit DML operations are not performed for these operations. And using begin..end blocks not needed for every method invoking, either.

Your issue stems from the fact the neccessity of invoking Dbms_Network_Acl_Admin.Add_Privilege method with privilege => 'connect' option also. So you can use the following :

BEGIN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
                                    acl         => 'apex_user.xml',
                                    description => 'access to apex email',
                                    principal   => 'DBUSER',
                                    is_grant    => TRUE,
                                    privilege   => 'connect',
                                    start_date  => SYSTIMESTAMP,
                                    end_date    =>Null
                                    );
  DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
                                       acl       => 'apex_user.xml',
                                       principal => 'DBUSER',
                                       is_grant  => true,
                                       privilege => 'connect'
                                       );

  DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
                                       acl       => 'apex_user.xml',
                                       principal => 'DBUSER',
                                       is_grant  => true,
                                       privilege => 'resolve'
                                       );


  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
                                    acl         => 'apex_user.xml',
                                    host        => 'smtp.gmail.com',
                                    lower_port  =>587,
                                    upper_port  =>587
                                    );
 END;

With the following query all privileged accesses could be checked ( through SYS or SYSTEM schemas ):

select a.host,p.*
  from dba_network_acl_privileges p
  join dba_network_acls a on a.aclid = p.aclid
 order by a.host, p.principal, p.privilege;

1) IMHO smtp.gmail.com requires secured connection and authentication but package utl_mail is not supporting these functions. You can achieve this with utl_smtp.

2) The Apex_mail package run with the privileges of their definer (apex_scheama) and your acl list is defined for dbuser. Also here you have somehow do the smtp authentication .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!