Error occurs when sending email from database 11g triiger
one of the problems that occurred was executing the "demo_mail" package that sends emails.
The problem
Sending mail via UTL_TCP and UTL_SMTP failes
ERROR at line 1:
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_TCP", line 17
ORA-06512: at "SYS.UTL_TCP", line 246
ORA-06512: at "SYS.UTL_SMTP", line 115
Cause :
The Database user which execute the demo_mail package is not authorized to open connection and send a mail.
Solution :
suppose that the user executes the package is "Scott" and smtp_host is "email2.dhaman.org"
SQL> EXECUTE DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'send_mail.xml',description => 'send_mail ACL',principal => 'scott',is_grant => true,privilege => 'connect');
PL/SQL procedure successfully completed.
SQL> EXECUTE DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl =>'send_mail.xml',principal => 'scott',is_grant => true,privilege => 'resolve')
PL/SQL procedure successfully completed.
SQL> EXECUTE DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'send_mail.xml',host => 'email2.dhaman.org')
PL/SQL procedure successfully completed.
SQL> COMMIT;
Commit complete.
now re execute the package again.It will work.
as SYS:
exec DBMS_NETWORK_ACL_ADMIN.DROP_ACL('mailserver_acl.xml');
exec DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('mailserver_acl.xml','Comment','SILVIO',TRUE,'connect');
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('mailserver_acl.xml','*');
commit;
as SILVIO:
select utl_inaddr.get_host_address('z-dina-db') from dual;
SQL> select utl_inaddr.get_host_address('z-dina-db') from dual;
select utl_inaddr.get_host_address('z-dina-db') from dual
*
ERROR at line 1:
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_INADDR", line 19
ORA-06512: at "SYS.UTL_INADDR", line 40
ORA-06512: at line 1
as SYS:
SELECT ACL as ACL_PATH FROM DBA_NETWORK_ACLS
WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
select DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE('/sys/acls/mailserver_acl.xml','SILVIO','connect') from dual;
-- returns 1
select DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE('/sys/acls/mailserver_acl.xml','SILVIO','resolve') from dual;
-- returns NULL
exec DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('mailserver_acl.xml','SILVIO',TRUE,'resolve');
commit;
select DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE('/sys/acls/mailserver_acl.xml','SILVIO','connect') from dual;
-- returns 1
select DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE('/sys/acls/mailserver_acl.xml','SILVIO','resolve') from dual;
-- returns 1
as SILVIO:
SQL> select utl_inaddr.get_host_address('z-dina-db') from dual;
UTL_INADDR.GET_HOST_ADDRESS('Z-DINA-DB')
------------------------------------------------------------------------------------------------------------------------------------
10.223.6.223
So, only after assigning the 'resolve' privilege in addition to the 'connect' privilege I could successfully use the UTL_INADDR call.
Hope this helps.
Silviois the user name
Comments