Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Setup environment for smtp package

Re: Setup environment for smtp package

From: ผีเสื้อทรนง <boonmepsnl_at_yahoo.com>
Date: 12 Jan 2006 16:53:07 -0800
Message-ID: <1137113587.230840.55980@g44g2000cwa.googlegroups.com>


Because I want to send email by PLSQL so I search data in INTERNET .I found that if you want to sent mail by Oracle 8 i ,you must install jvm in oracle.Example the following article that I found : Real-time Messaging in Oracle: Send E-mails Programmatically from the Database (cont'd)

Oracle's UTL_SMTP Package
Oracle introduced the UTL_SMTP package in the 8i version of its database. (SMTP stands for Simple Mail Transfer Protocol, a 20-year-old protocol that uses TCP port 25 to establish communication between a client and a server.) Oracle designed the UTL_SMTP package to enable developers to send e-mails from the database.

You need 8i or a higher version with the Java Virtual Machine (JVM) installed to use UTL_SMTP. In addition, you have to have plsql.jar loaded into your database. Otherwise, you'll get the following exception when you call the UTL_SMTP APIs to send an e-mail: ORA-29540: class oracle/plsql/net/TCPConnection does not exist.

By default, the $ORACLE_HOME/javavm/install/initjvm.sql main script (which installs JVM) does not run the initplsj.sql script that loads the plsql.jar file into your database. Run the $ORACLE_HOME/RDBMS/ADMIN/initplsj.sql script manually as a SYS or INTERNAL user to resolve the problem. If you don't have this script available, you can either request it from Oracle Support or as a workaround simply load plsql.jar directly using the loadjava utility:

loadjava -user sys/password_at_database -resolve plsql/jlib/plsql.jar

UTL_SMTP APIs
I use the following APIs of the UTL_SMTP package in this Solution's code:

OPEN_CONNECTION() opens the connection to SMTP server. HELO() performs the initial handshake with the SMTP server after connecting, and it identifies the sender for the server. MAIL() initiates a mail transaction with a server but does not actually send a message.
RCPT() identifies the recipient of the message. In order to send a message to multiple recipients, you have to call this procedure multiple times. Each RCPT invocation schedules delivery to a single e-mail address.
DATA() specifies the body of the e-mail. QUIT() terminates an SMTP session and disconnects from the server. To utilize the APIs, put the following calls in your program in the order specified:

Call OPEN_CONNECTION
Call HELO
Call MAIL
Call RCPT for each recipient
Format the body of the e-mail and call MAIL Call QUIT Received on Thu Jan 12 2006 - 18:53:07 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US