<$BlogRSDUrl$>

Wednesday, March 09, 2005

The following question was asked on Oracle-L just recently.
We are sending the e-mails using the mailx client from the unix cron jobs.
The new requirement is, after the stored procedure is executed using the job
scheduler (dbms_job), we would like to send the e-mail from Oracle. Is there
a way to send the e-mail from oracle?

The answer to this does depend on version and requirements, but yes you can send emails from Oracle in all versions from 8.1.7 up.

If you just want simple mail then the UTL_SMTP package will allow you to send emails quite simply. I have uploaded a sample package that you can use for this purpose here. If you want to send attachments or large messages (larger than the 32k varchar2 limit) then prior to 10g you will need to adopt some other technique. One possible technique is to load a fully capable Java mail client into the database and create a java stored procedure for this code. Tom Kyte covers this in his Expert one-on-one Oracle book.

It is also worth looking at the HTMLDB 1.6 release which uses a wrapper around UTL_SMTP to queue and send mail. This asynchronous queue related technique is suitable for high volume mailings as typically a mail server session will not respond in a suitable timeframe for a transaction processing application.

10g itself introduces the UTL_MAIL package. This allows attachments etc to be sent.

0 Comments
0 Comments: Post a Comment