Configure the UTL Mail in Oracle Database

Configure the UTL Mail in Oracle Database

UTL_MAIL is package in Sys schema which is able to used for sending mail in Oracle. You can send mail from UTL_MAIL by using code in your package.

Steps to Configure the UTL MAIL in Oracle

1. Connect with sysdba user
sqlplus '/ as sysdba'

2. Execute the utlmail.sql script
@$ORACLE_HOME/rdbms/admin/utlmail.sql

3. Execute the prvtmail.plb script
@$ORACLE_HOME/rdbms/admin/prvtmail.plb

4. Set smtp_server information in init.ora or spfile.ora
alter system set smtp_out_server = 'SMTP_SERVER_IP_ADDRESS:SMTP_PORT' scope=both;

Note:25 = Default SMTP Port

How to send an email
1. Connect with the user or sysdba users
sqlplus '/ as sysdba'

2. Utl Mail has send procedure for sending the mail:
exec utl_mail.send(sender => 'sunny@wordpress.com', recipients => 'sunny@wordpress.com', subject => 'Test subject', message => 'Test message');

3. Check the email id, to verify the email receipt.
Note: Access grant to SCOTT user for utl_mail package.
grant execute permission on UTL_MAIL to SCOTT;

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s