From oracle 11gR2 onwards ACLs(Access control list) are mandatory to send mail from procedure using UTL_MAIL or UTL_SMTP. For this make sure XDB component is installed.

If XDB component is not installed Check - How to install XDB component in oracle.

 

Verify whether UTL_MAIL and UTL_SMTP is installed or not.

select object_name,object_type,owner from dba_objects where object_name in('UTL_MAIL','UTL_SMTP');

no rows selected.

 

As in our case, both utl_mail and utl_stmp are not installed.

 

Install the packages:

[host@oracle]$ cd $ORACLE_HOME/rdbms/admin

[host@oracle]$sqlplus / as sysdba

SQL> @utlmail

SQL> @utlsmtp

SQL> @prvtmail.plb

SQL> GRANT EXECUTE ON utl_mail TO PUBLIC;

SQL> GRANT EXECUTE ON utl_smtp TO PUBLIC;

 

Set the SMTP_OUT_SERVER parameter

NOTE - Please check with your OS admin for this smtp mail server hostname/hostname.

SQL> alter system set smtp_out_server='smtp-server.mail.eraazi.com' scope=both;

System altered.

If smtp_out_server is set incorrectly ,then it will throw error -: ORA-29278: SMTP transient error: 421 Service not available

Now create ACLS
Suppose the user SCOTT want to send mail from procedure.

--- creating ACL as below 
exec DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('scott_utl_mail.xml','Allow mail to be send','SCOTT', TRUE, 'connect');
commit;
----Grant the connect and resource privilege as below
exec DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('scott_utl_mail.xml','SCOTT', TRUE, 'connect');
exec DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('scott_utl_mail.xml' ,'SCOTT', TRUE, 'resolve');
exec DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('scott_utl_mail.xml','*',25);
commit;

 

Test whether user SCOTT is  able to send mail or not

 

SQL>conenct scott/tiger
connected
SQL>EXECUTE UTL_MAIL.SEND(SENDER=>'[email protected]',RECIPIENTS=>'rpatro@eraazi.com,[email protected]', MESSAGE=>'Hello World');


 

Dictionary tables for ACLS

 

SQL> select * from dba_network_acls;

SQL> select * from dba_network_acl_privileges;

 

SEE - COLLECTION OF USEFUL DATABASE SCRIPTS

 

SEE NEW FEATURES OF ORACLE 12.2:

  •  Upgrade oracle database from 12cR1 to 12cR2 version:
  •  Convert non-partitioned table to partitioned table online
  • Datapump New features - Oracle 12.2 Version
  • Lock Account Automatically With INACTIVE_ACCOUNT_TIME
  • PDB Lockdown Profiles in  Oracle 12.2
  • SQL*Plus History In Oracle 12.2
  • Long Identifiers In Oracle 12.2
  • DBMS_TNS  package for tnsping in  database Oracle 12.2
  • Spool CSV In Oracle 12.2
  • VARIABLE new feature  in Oracle 12.2
  • Move table online in Oracle 12.2
  • Read only Partition in Oracle 12.2
  • Split partition online oracle 12.2
ORACLE SECURITY


Related Topics

orapwd tool for password file in oracle
how to send mail using utl_mail in oracle 11g
How to move AUD$ table to another tablespace using DBMS_AUDIT_MGMT
Unified audit trail in Oracle 12c
ENABLE_DDL_LOGGING in oracle 12c
PDB Lockdown Profiles in Oracle 12.2
Purge AUD$ table using DBMS_AUDIT_MGMT
Open wallet automatically after starting the database
how to use DBMS_PRIVILEGE_CAPTURE to capture privs in oracle 12c
Lock account automatically with INACTIVE_ACCOUNT_TIME

You May Also Like

How to change spfile in Oracle RAC.
How to monitor parallel queries in oracle db
shell script for file system alert
oraversion utility in oracle 18c - New feature
How to move AUD$ table to another tablespace using DBMS_AUDIT_MGMT
DEFERRED_SEGMENT_CREATION parameter in oracle
Find sessions consuming lot of CPU
Steps for upgrading weblogic 12.1.2 to 12.1.3
ORA-32771: cannot add file to bigfile tablespace
SKIP_CONSTRAINT_ERRORS as DATA_OPTION in impdp

From This Website

Deinstall Management Agents Oracle 12c cloud control
ERROR: No checkpoint table specified for ADD REPLICAT
How to move AUD$ table to another tablespace using DBMS_AUDIT_MGMT
How to enable active dataguard in physical standby database
Ansible script to run script on remote server and fetch the output
How to flashback a Pluggable database ( PDB) in oracle 12.2
REUSE_DUMPFILES parameter in EXPDP
DBMS_PARALLEL_EXECUTE in oracle PL/SQL
SKIP_CONSTRAINT_ERRORS as DATA_OPTION in impdp
ORA-32771: cannot add file to bigfile tablespace