ORACLE: UTL_MAIL

The UTL_MAIL database package is used to manage email. It allows you to send an email
message directly from the database server, with cc and bcc, and also catering for RAW attachments.
This package is not installed by default due to obvious security reasons, but needs to be installed
manually via two scripts: utlmain.sql and prvtmail.plb, both of which are in the rdbms/admin
directory under the Oracle Home.
sqlplus / as sysdba
SQL> @?/rdbms/admin/utlmail.sql
SQL> @?/rdbms/admin/prvtmail.plb
However, in the case of an Oracle 12c Database, it is not enough to run these scripts in the root
container. You need to run them in each PDB in which you need UTL_MAIL to work.
This also requires the SMTP_OUT_SERVER initialization parameter to be defined in the init.ora
file. This parameter specifies the SMTP host and port to which UTL_MAIL will send email to. You
can specify multiple servers in this parameter, and if the first is unavailable, the next one is used,
and so on.
Suppose you do not specify SMTP_OUT_SERVER explicitly, then the SMTP server name used by
UTL_MAIL will default to the value of DB_DOMAIN with a port number of 25.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *