Oracle Mail

Hello Readers,

This post would focus on sending mails from Oracle. Of all the nice packages, utl_mail package can be used directly to send emails from Oracle objects.  By default, sending mails is disabled from Oracle due to security reasons. To enable, DBA has to run utlmail.sql script and set smtp_out_server parameter in init.ora file.

If utl_mail package is not enabled, you may receive the following error:


Error report:

ORA-06550: line 2, column 1:

PLS-00201: identifier 'UTL_MAIL.SEND' must be declared

ORA-06550: line 2, column 1:

PL/SQL: Statement ignored

06550. 00000 -  "line %s, column %s:\n%s"

*Cause:    Usually a PL/SQL compilation error.

*Action:

Now assuming db is configured to send mails, you can use the send procedure to send emails as follows:

begin

utl_mail.send (

sender => 'someone@somewhere.com',

recipients => 'someoneelse@somewhere.com',

subject => 'Mail from Oracle',

message => 'Look, I can send mails from Oracle...',

mime_type => 'text; charset=us-ascii'

);

end;

Happy mailing…

Advertisements

About Badal Chowdhary

I am a Software Engineer by profession. I have done SCJP and SCWCD certifications. Like working on cutting edge technologies and frameworks. Driven by challenges and fascinated by technology. I love playing and watching sports: Cricket, Ping Pong, Tennis, Badminton, Racket Ball and Gym.
This entry was posted in Oracle and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s