Tuesday, 15 May 2012

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>








3 comments:

  1. Hi,

    I am getting the following error while executing
    the statement :
    SQL> @/app/oracle/10g/rdbms/admin/prvtmail.plb .



    Errors for PACKAGE BODY UTL_MAIL:

    LINE/COL ERROR
    -------- -------------------------------------------------
    309/5 PL/SQL: SQL Statement ignored
    310/10 PL/SQL: ORA-00942: table or view does not exist
    315/7 PL/SQL: SQL Statement ignored
    316/12 PL/SQL: ORA-00942: table or view does not exist


    Kindly suggest a solution to resolve this.

    ReplyDelete
  2. Bhaskarita,

    Have @/app/oracle/10g/rdbms/admin/utlmail.sql run without error
    it should look like below if no then run it again or send me error

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

    Package created.

    Synonym created.


    ReplyDelete
  3. awful piece of information, I had come to know about your blog from my friend vimal, mumbai,i have read atleast 13 posts of yours by now, and let me tell you, your blog gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a million once again, Regards, Synonyms

    ReplyDelete