The UTL_MAIL
package is a utility for managing email which includes commonly used email features, such as attachments, CC, and BCC.
This chapter contains the following topics:
Security Model
Operational Notes
Rules and Limits
UTL_MAIL
is not installed by default because of the SMTP_OUT_SERVER
configuration requirement and the security exposure this involves. In installing UTL_MAIL
, you should take steps to prevent the port defined by SMTP_OUT_SERVER
being swamped by data transmissions.
This package is now an invoker's rights package and the invoking user will need the connect privilege granted in the access control list assigned to the remote network host to which he wants to connect.
Note:
For more information, see Managing Fine-grained Access to External Network Services in Oracle Database Security GuideYou must both install UTL_MAIL
and define the SMTP_OUT_SERVER.
To install UTL_MAIL:
sqlplus sys/<pwd> SQL> @$ORACLE_HOME/rdbms/admin/utlmail.sql SQL> @$ORACLE_HOME/rdbms/admin/prvtmail.plb
You define the SMTP_OUT_SERVER
parameter in the init
.ora
rdbms
initialization file. However, if SMTP_OUT_SERVER
is not defined, this invokes a default of DB_DOMAIN
which is guaranteed to be defined to perform appropriately.
Table 230-1 UTL_MAIL Package Subprograms
Subprogram | Description |
---|---|
Packages an email message into the appropriate format, locates SMTP information, and delivers the message to the SMTP server for forwarding to the recipients |
|
Represents the |
|
Represents the |
This procedure packages an email message into the appropriate format, locates SMTP information, and delivers the message to the SMTP server for forwarding to the recipients. It hides the SMTP API and exposes a one-line email facility for ease of use.
UTL_MAIL.SEND ( sender IN VARCHAR2 CHARACTER SET ANY_CS, recipients IN VARCHAR2 CHARACTER SET ANY_CS, cc IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, bcc IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, subject IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, message IN VARCHAR2 CHARACTER SET ANY_CS, mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=us-ascii', priority IN PLS_INTEGER DEFAULT 3, replyto IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL);
Table 230-2 SEND Procedure Parameters
Parameter | Description |
---|---|
|
Email address of the sender |
|
Email addresses of the recipient(s), separated by commas |
|
Email addresses of the CC recipient(s), separated by commas, default is |
|
Email addresses of the BCC recipient(s), separated by commas, default is |
|
String to be included as email subject string, default is |
|
Text message body |
|
Mime type of the message, default is |
|
Message priority, which maps to the X-priority field. 1 is the highest priority and 5 the lowest. The default is 3. |
|
Defines to whom the reply email is to be sent |
This procedure is the SEND
Procedure overloaded for RAW
attachments.
UTL_MAIL.SEND_ATTACH_RAW ( sender IN VARCHAR2 CHARACTER SET ANY_CS, recipients IN VARCHAR2 CHARACTER SET ANY_CS, cc IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, bcc IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, subject IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, message IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, mime_type IN VARCHAR2 DEFAULT CHARACTER SET ANY_CS DEFAULT 'text/plain; charset=us-ascii', priority IN PLS_INTEGER DEFAULT 3, attachment IN RAW, att_inline IN BOOLEAN DEFAULT TRUE, att_mime_type IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT 'text/plain; charset=us-ascii', att_filename IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, replyto IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL);
Table 230-3 SEND_ATTACH_RAW Procedure Parameters
Parameter | Description |
---|---|
|
Email address of the sender |
|
Email addresses of the recipient(s), separated by commas |
|
Email addresses of the CC recipient(s), separated by commas, default is |
|
Email addresses of the BCC recipient(s), separated by commas, default is |
|
String to be included as email subject string, default is |
|
Text message body |
|
Mime type of the message, default is |
|
Message priority, which maps to the X-priority field. 1 is the highest priority and 5 the lowest. The default is 3. |
|
|
|
Specifies whether the attachment is viewable inline with the message body, default is |
|
Mime type of the attachment, default is 'application/octet' |
|
String specifying a filename containing the attachment, default is |
|
Defines to whom the reply email is to be sent |
This procedure is the SEND
Procedure overloaded for VARCHAR2
attachments.
UTL_MAIL.SEND_ATTACH_VARCHAR2 ( sender IN VARCHAR2 CHARACTER SET ANY_CS, recipients IN VARCHAR2 CHARACTER SET ANY_CS, cc IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, bcc IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, subject IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, message IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL, mime_type IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT 'text/plain; charset=us-ascii', priority IN PLS_INTEGER DEFAULT 3, attachment IN VARCHAR2 CHARACTER SET ANY_CS, , att_inline IN BOOLEAN DEFAULT TRUE, att_mime_type IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT 'text/plain; charset=us-ascii, att_filename IN VARCHAR2CHARACTER SET ANY_CS DEFAULT NULL, replyto IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL);
Table 230-4 SEND_ATTACH_VARCHAR2 Procedure Parameters
Parameter | Description |
---|---|
|
Email address of the sender |
|
Email addresses of the recipient(s), separated by commas |
|
Email addresses of the CC recipient(s), separated by commas, default is |
|
Email addresses of the BCC recipient(s), separated by commas, default is |
|
String to be included as email subject string, default is |
|
Text message body |
|
Mime type of the message, default is |
|
Message priority, which maps to the X-priority field. 1 is the highest priority and 5 the lowest. The default is 3. |
|
Text attachment |
|
Specifies whether the attachment is inline, default |
|
Mime type of the attachment, default is |
|
String specifying a filename containing the attachment, default is |
|
Defines to whom the reply email is to be sent |