UTL_MAIL Package in Oracle

UTL_MAIL Package in Oracle

In this article, I am going to discuss UTL_MAIL Package in Oracle with Examples. Please read our previous article where we discussed UTL_FILE Exceptions in Oracle. This UTL_MAIL Package in Oracle is used to send mail.

UTL_MAIL Package in Oracle

This is a utility for managing emails. This requires the setting of the SMTP_OUT_SERVER database initialization parameter. This is a simple mail transfer protocol. DBA should have the mail or mail server information. The package provides the following procedures:

  • SEND – Sends messages without attachments
  • SEND_ATTACH_RAW – Sends messages with binary attachments (Image)
  • SEND_ATTACH_VARCHAR2 – Sends messages with text attachments(.txt)
How does UTL_MAIL Work in Oracle?

Step 1: Create the UTL_MAIL package.

By default, the UTL_MAIL package is not installed in the database. The Database Admin needs to install this package in the database by running the below files.

@$ORACLE_HOME/rdbms/admin/utlmail.sql

@$ORACLE_HOME/rdbms/admin/prvtmail.plb

Step 2: Define the SMTP_OUT_SERVER in the init.ora

Step 3: The DBA needs to grant execute privilege on UTL_MAIL to a USER/PUBLIC.

Step 4: The DBA needs to add a record in ACL (Access Control List) using the package DBMS_NETWORK_ACL_ADMIN.

Step 5: Now any user can access the UTL_MAIL.

Note: These four steps are done by DBA. Once the DBA completes all these steps then the user can access the UTL_MAIL.

In the next article, I am going to discuss Sequences in Oracle with Examples. Here, in this article, I try to explain UTL_MAIL Package in Oracle with Examples. I hope you enjoy this UTL_MAIL Package in Oracle article.

Leave a Reply

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