The Utl_Smtp package provides all the primitives required to send email
(with character and/or binaray attachments) by making calls from
database PL/SQL.
The Utl_Smtp primitives are relatively low level, and even a simple task
like sending a plain text email with no attachments requires a number of
calls. The package maildemo in
maildemo.sql
provides a wrapper around Utl_Smtp.
Note: it uses
the Utl_Encode package which is new in Oracle9i.
An alternative version of maildemo for Oracle8i is avaiable in
maildemo8i.sql
This uses an explicit implementation of encoding available in
bs64demo8i.sql.
The maildemo package presents a higher level API
for just such simple tasks making it easy to...
- send a short plain text email with no attachments via a single call
- send a long email in plain text or HTML by...
- addressing it and setting the message MIME-type
- defining the message piecewise
- send an email with attachments by...
- addressing it and setting the message MIME-type to MULTIPART
- defining the message piecewise
- adding character attachment(s) with defined MIME-type
- adding binary attachment(s) with defined MIME-type
and encoding scheme
- stating whether each attachment is to be inline or not
- send an email in a multibyte character set (eg for Chinese, Japanes or Korean)
The maildemo package thus illustrates the use of the lower level Utl_Smtp API.
(It uses about half of the available primitives.)
It is not however intended to be a complete programmatic equivalent of an
interactive email client. Such a package is under consideration, in the
first instance for exposure on OTN and then possibly for inclusion
in a database release.
The anonymous blocks in
mailexample.sql
and in
mailexample8i.sql
for Oracle8i
illustrate the use of the maildemo API.