UTL_SMTP, introduced for the first time in Oracle 8.1.6, is an interface to the Simple Mail Transfer Protocol. It requires that you have an SMTP server in your network somewhere – most sites I have been to have at least one SMTP server running as it is the most popular method for sending mail. The UTL_SMTP package is best suited for sending small, text only e-mails from the database. While its API supports the sending of attachments and everything else – it is left to you to actually encode the multi-part document – for example turning binary attachments into mime-encoded documents.
In this document we'll visit the example introduced in the DBMS_JOB section, which used UTL_SMTP, build upon it by adding additional functionality. We will also look at an alternative to UTL_SMTP that provides somewhat much more functionality – including the ability to easily send attachments with the e-mail. Since SMTP is a very
low level protocol, we'll reuse existing public domain code to get an SMTP interface at much higher level – and we'll get it with very little code.