Monday, 7 April 2014

Configure UTL_MAIL in 10g


In case you want to send email from oracle 10g yu must need install and set up UTL_MAIL
Pakage . You must need to login with sys user first



SQL> show user 
 USER is "SYS" 


The UTL_MAIL package provides a simple API to allow email to be sent from PL/SQ
The package is loaded by running the following scripts. 

SQL> host echo $ORACLE_HOME
/app/oracle/10g

SQL> @/app/oracle/10g/rdbms/admin/utlmail.sql

Package created.

Synonym created.
SQL> @/app/oracle/10g/rdbms/admin/prvtmail.plb

Package body created.

No errors.

Next SMTP_OUT_SERVER parameter must be set to identify the SMTP server.

SQL> alter system set smtp_out_server ='127.0.0.1:25' scope=both;

System altered.


 By using  code we can send mail


SQL> create or replace procedure vani as
2 subtext varchar(20) default 'abc';
3 begin
4 Utl_Mail.send(
5 sender => 'dba.vanitasharma@gmail.com',
6 recipients => 'dba.vanitasharma@gmail.com',
7 cc=>'dba.vanitasharma@gmail.com',
8 subject => subtext,
9 mime_type=>'text/html; charset=us-ascii'
10 );
11 end;
12
13 /

Procedure created.

SQL> execute vani

PL/SQL procedure successfully completed.

SQL>


No comments:

Post a Comment